此内容没有您所选择的语言版本。

Chapter 8. Tracing a message through a route


Tracing allows you to intercept a message as it is routed from one node to another. You can trace messages through your routing context to see where you can optimize and fine tune your routing context’s performance. This tutorial shows you how to trace a message through a route.

Goals

In this tutorial you complete the following tasks:

  • Run the ZooOrderApp in the Fuse Integration perspective
  • Enable tracing on the ZooOrderApp
  • Drop messages onto the ZooOrderApp and track them through all route nodes

Prerequisites

To start this tutorial, you need the ZooOrderApp project resulting from one of the following:

Setting up your Fuse Integration perspective

To set up your workspace to facilitate message tracing:

  1. Click the Open Perspective icon button on the right side of the tool bar, and then select Fuse Integration from the list:

    tutPerspListFIPselected

    The Fuse Integration perspective opens in the default layout:

    TutFIP 63
  2. Drag the JMX Navigator tab to the far right of the Terminal tab and drop it there:

    ftTutFIPrearrange

    This arrangement provides more space for Diagram View to display the routing context’s nodes graphically, which makes it easier for you to visually trace the path that messages take in traversing the routing context.

    Note

    To make it easy to access a routing context .xml file, especially when a project consists of multiple contexts, the tooling lists them under the Camel Contexts folder in Project Explorer.

    Additionally, all routes in a routing context are displayed as icons directly under their context file entry. To display a single route in the routing context on the canvas, double-click its icon in Project Explorer. To display all routes in the routing context, double-click the context file entry.

    TutCamelContextsFolderPE

Starting message tracing

To start message tracing on the ZooOrderApp project:

  1. In Project Explorer, expand the ZooOrderApp project to expose src/main/resources/OSGI-INF/blueprint/blueprint.xml.
  2. Right-click src/main/resources/OSGI-INF/blueprint/blueprint.xml to open the context menu.
  3. Select Run As Local Camel Context (without tests).

    Note

    If you select Local Camel Context, the tooling reverts to running without tests because you have not yet created a JUnit test for the ZooOrderApp project. You will do that later in Chapter 9, Testing a route with JUnit.

  4. In JMX Navigator, expand Local Processes.

    tutMsgTrJMXLocalProcessess
  5. Right-click the maven [ID] node and then select Connect.
  6. Expand the elements of your route:

    tutMsgTrJMXLCCexpanded
  7. Right-click the Routes node and then select Start Tracing:

    tutTraceStart

    The tooling displays a graphical representation of your routing context in Diagram View:

    tutDiagramNodes

    To see all message flow paths clearly, you probably need to rearrange the nodes by dragging them to fit neatly in the Diagram View tab. You may also need to adjust the size of the other views and tabs in Red Hat JBoss Developer Studio to allow the Diagram View tab to expand.

Dropping messages on the running ZooOrderApp project

To drop messages on the running ZooOrderApp project:

  1. In Project Explorer, expand ZooOrderApp/src/data, so that you can access the message files (message1.xml through message6.xml):

    tutMsgFiles
  2. Drag message1.xml and drop it on the _context1>Endpoints>file>src/data?noop=true node in JMX Navigator:

    tutJMXLocalCntxtExpanded

    As the message traverses the route, the tooling traces and records its passage at each step.

Configuring Messages View

You must refresh the Messages View before it will display message traces. You also need to configure the columns in Messages View if you want them to persist across all message traces.

  1. Open the Messages View.
  2. Click the refresh (Refresh button) on top, right of the panel’s menu bar to populate the view with message1.xml's message traces.
  3. Click the View Menu icon icon on the panel’s menu bar, and select Configure Columns to open the Configure Columns wizard:

    TutConfigColsDefaults
    Note

    Notice that the message header, Destination, which you set for the messages in your routing context, appears in the list.

    You can include or exclude items from Messages View by selecting or deselecting them. You can rearrange the columnar order in which items appear in Messages View by highlighting individual, selected items and moving them up or down in the list.

  4. In the Configure Columns wizard, select and order the columns this way:

    tutMsgVCnfgColsMnu

    These columns and their order will persist in Messages View until you change them again.

Note

You can control columnar layout in all of the tooling’s tables. Use the drag method to temporarily rearrange tabular format. For example, drag a column’s border rule to expand or contract its width. To hide a column, totally contract its borders. Drag the column header to relocate a column within the table. For your arrangement to persist, you must use the View Configure Columns method instead.

Stepping through message traces

To step through the message traces:

  1. Drag message2.xml and drop it on the _context1>Endpoints>file>src/data?noop=true node in JMX Navigator.
  2. Switch from Console to Messages View.
  3. In Messages View, click the refresh (Refresh button) to populate the view with message2.xml message traces.

    Each time you drop a message on in JMX Navigator, you need to refresh Messages View to populate it with the message traces.

  4. Click one of the message traces to see more details about it in Properties view:

    tutTraceDetails2

    The tooling displays the details about a message trace (including message headers when they are set) in the top half of the Properties view and the contents of the message instance in the bottom half of the Properties view. So, if your application sets headers at any step within a route, you can check the Message Details to see whether they were set as expected.

    You can step through the message instances by highlighting each one to see how a particular message traversed the route and whether it was processed as expected at each step in the route.

  5. Open Diagram View, to see that the associated step in the route is highlighted:

    TutMsgTraceDiagNode

    The tooling draws the route in Diagram View, tagging paths exiting a processing step with timing and performance metrics (in milliseconds). Only the metric Total exchanges is displayed in the diagram.

  6. Hover the mouse pointer over the displayed metrics to reveal additional metrics about message flow:

    tutDVnodeMetrics
    • Mean time the step took to process a message
    • Maximum time the step took to process a message
    • Minimum time the step took to process a message
  7. Optionally, you can drag and drop the remaining messages in ZooOrderApp/src/data/ into the _context1>Endpoints>file>src/data?noop=true node in JMX Navigator at any time, as long as tracing remains enabled.

    On each subsequent drop, remember to click the refresh (Refresh button) to populate Messages View with the new message traces.

  8. When done:

    • In JMX Navigator, right-click _context1 and select Stop Tracing Context.
    • Open the Console and click the Stop icon button in the upper right of the panel to stop the Console. Then click the Clear icon button to clear console output.

Next steps

In the Chapter 9, Testing a route with JUnit tutorial, you create a JUnit test case for your project and run your project as a Local Camel Context.

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.