Red Hat Training

A Red Hat training course is available for Red Hat Fuse

Chapter 4. To Trace a Message Through a Route

Abstract

This tutorial walks you through the process of tracing a message through a route.

Goals

In this tutorial you will:
  • run a route in the Fuse Integration perspective
  • enable tracing on your route
  • drop messages onto your route and track them through the route's nodes

Prerequisites

To complete this tutorial you will need the simple-route project you updated in Chapter 3, To Add a Content-Based Router.

Procedure

To trace a message through your route:
  1. Select WindowOpen PerspectiveOther...Fuse Integration to open the Fuse Integration perspective as shown in Figure 4.1, “Fuse Integration perspective”).

    Figure 4.1. Fuse Integration perspective

    Fuse Integration perspective layout
    Note
    You can use the Open Perspective icon ( Open Perspective icon ) in the perspectives tab to access the list of available perspectives.
  2. In Project Explorer, expand the simple-route project to expose the src/main/resources/META-INF/spring/camel-context.xml file.
  3. Select Run AsLocal Camel Context (without tests) from the camel-context.xml file's context menu.
  4. In Fuse JMX Navigator, expand Local Processes.
  5. Double click Local Camel Context [id] to connect to the context and expand the elements of your route as shown in Figure 4.2, “Route elements in Fuse JMX Navigator”).

    Figure 4.2. Route elements in Fuse JMX Navigator

    Route expansion in Fuse JMX Navigator
  6. In Fuse JMX Navigator, select Start Tracing from the camel-1 node's context menu.
    The tooling displays a graphical representation of your route in Diagram View.
  7. In Diagram View, drag the nodes to rearrange them, so you can clearly see the route's flow paths.
    Note
    You will have to rearrange the nodes in Diagram View each time you select a different node in Fuse JMX Navigator.
  8. In Project Explorer, expand simple-route/src/data, so you can access the message1.xml and message2.xml files as shown in Figure 4.3, “Message files in simple-route project”.

    Figure 4.3. Message files in simple-route project

    Message source files in simple-route application
  9. Drag message1.xml and drop it on .../camel-1/Endpoints/file/src/data?noop=true.
    As the message traverses the route, the tooling traces and records its passage at each step and displays the results in Messages View.
  10. Repeat Step 9, but this time drag message2.xml and drop it on .../camel-1/Endpoints/file/src/data?noop=true.
  11. In the bottom, right panel, switch from Console to Messages View.
  12. In Fuse JMX Navigator, click camel-1 to populate Messages View with the traces of each message.
    As shown in Figure 4.4, “Fuse Integration perspective's message tracing components”, the tooling draws the route in Diagram View, tagging paths exiting a processing step with timing and performance metrics. Only the metric Total exchanges is displayed in the diagram. Hovering over the displayed metrics reveals additional metrics about message flow:
    • 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

    Figure 4.4. Fuse Integration perspective's message tracing components

    Message tracing in Fuse Integration perspective
  13. In Messages View, click a message instance.
    The associated step in the route is highlighted in Diagram View. You can step through the message instances to see how a particular message traversed the route and whether it was processed as expected at each step in the route.
    The tooling displays the details about a message instance in the top half of the Properties panel and the contents of the message instance, including any headers, in the bottom half of the Properties panel. So, if your application sets headers at any step within a route, you can check whether they are set as expected.
    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. If you want your arrangement to persist, use the View MenuConfigure Columns... method instead. To access it, click the View Menu icon icon on the panel's menu bar.
  14. When done, switch back to the Console and click the stop button ( Stop icon ) in the upper, right side of its pane.

Next steps

You can run the route with a JUnit test case, as described in Chapter 5, To Test a Route with JUnit.

Further reading

To learn more about message enrichment see: