Red Hat Training

A Red Hat training course is available for Red Hat Fuse

Chapter 15. Running the Camel Debugger

You can run the Camel debugger on locally running routing contexts and on remotely running routing contexts. The same basic features and functionality are available in both debugging modes.

  • Local debugging — Runs the debugger on the routing context running in the same JVM with Fuse Tooling. This mode is activated by selecting the project’s routing context in the Project Explorer view and selecting Debug AsLocal Camel Context from the context menu.
  • Remote debugging — Runs the debugger on a routing context running in a separate JVM either on the local machine or on a remote machine. This mode requires a supported runtime server installed on the local machine or on an accessible remote machine. It is activated by creating and running a debug launch configuration that specifies the remote runtime’s connection details.
Note

If your project contains Java code, you can use the standard Eclipse Java debugging tools to debug it. For local debugging, it is automatically available. For remote debugging, you need to use the Remote Camel Context and Java launch option (see Section 15.2, “Debugging a remotely running routing context”).

Note

You must set breakpoints in your routing context file before you can start the Camel debugger.

15.1. Debugging a locally running routing context

Procedure

  1. In the Project Explorer view, select the routing context file you want to debug.
  2. Right-click the selected file to open the context menu, and then select Debug AsLocal Camel Context.

    Fuse Tooling builds the Camel route, starts Apache Camel, starts the routing context, enables JMX, starts the route(s) in the routing context, adds the breakpoints to the nodes, and enables the Camel debugger.

    The Camel debugger suspends execution of the routing context at the first breakpoint hit (received a message), and prompts you to indicate whether you want it to open the Debug perspective.

    DBCnfrmSwitchToDBView
  3. Click Yes to open the Debug perspective.

    The Debug perspective opens with the routing context suspended at the first breakpoint encountered in the running routing context.

    Important

    Breakpoints are held for a maximum of five minutes, after which debugging automatically resumes, moving on to the next breakpoint or to the end of the routing context.

    openDBPerspective
    Note

    To see the console output, open the Console view if it was not open when you switched perspectives.

    Note

    By default, the Debug perspective displays the Outline view, which provides the means to switch between separate routes in a running routing context. If your routing context contains a single route, closing the Outline view frees space to expand the other views, making it easier to access and examine debugger output.

Watching message exchanges progress through the routing context

Click stepover co (Step Over) to jump to the next node of execution in the routing context. Click resume co (Resume) to continue execution at the next active breakpoint in the routing context.

debug StateChange

15.2. Debugging a remotely running routing context

Prerequisites

Setting up and starting remote debugging

With the project deployed on Fuse and the server stopped, you need to set up and start remote debugging as follows:

  • Start Fuse in debug mode outside of Red Hat Developer Studio.
  • In Developer Studio, set breakpoints on nodes in the project’s routing context, which is open in the route editor.
  • Create a remote Camel context debug configuration and run it.
  • Connect to Fuse runtime in the JMX Navigator view.
  • Drop test messages in the JMX Navigator view on the input node of the Camel route running inside the Fuse runtime.
  • Use any of the Camel debugger’s tools for debugging routes.

Procedure

To set up and start remote debugging:

  1. Open a terminal outside of Red Hat Developer Studio, and enter

    $ [{prodname}_HOME]/bin/{prodname} debug
  2. Wait for the Fuse splash screen to appear, and then return to the Fuse Integration perspective in JBoss Developer Studio.
  3. In the tooling’s route editor, with the project’s routing context open in the Design tab, set breakpoints on the nodes of interest. For details, see Chapter 14, Setting Breakpoints.
  4. In the Project Explorer view, right-click the project’s root and select Debug AsDebug Configurations to open the Debug Configurations wizard:

    NewRemoteDBLaunchCnfg
  5. In the configuration type pane, select either Remote Camel Context or Remote Camel Context and Java , and then click New Configuration :

    CCJdbNewLaunchCnfg

    For both the Remote Camel Context and Remote Camel Context and Java options, you need to specify configuration details on the Camel and JMX tabs.

    For the Remote Camel Context and Java option only, you also need to specify configuration details on the Connect tab.

    Note

    Unless your project contains Java code that you want to debug using the standard Eclipse Java debugging tools, select the Remote Camel Context option.

  6. In the Name field, enter a name for the new launch configuration.
  7. On the Camel tab, click the Browse button to locate the project’s routing context .xml file in the Open Resources dialog:

    CCdbSelCamelCntxt
    Note

    When you select a file in the Matching items pane, the tooling displays the file’s location, relative to the project root, at the bottom of the pane.

  8. In the Matching items pane, select your project’s routing context file from the list, and then click OK.

    The tooling inserts the file’s path into the Select Camel Context file field:

    CCJDbugCamelTabNew
  9. Click the JMX tab:

    RemoteDBJMXtabDefaults

    Edit the JMX connection details as follows:

    • JMX Uri — change :9011/jmxrmi to :1099/karaf-root

      If the Fuse server is running on a remote host, replace localhost with the DNS name or IP address of the remote host.

    • JMX User — enter admin.
    • JMX Password — enter admin.

      Important

      The values shown for JMX User and JMX Password are the Fuse admin user defaults, stored in the Fuse_HOME/etc/users.properties file. If your setup is different, enter the values specific to it.

      If you are creating a Remote Camel Context debug launch configuration, you are done. Skip to [debugCfgGo].

  10. Click the Connect tab:

    RemoteDBConnectTabDefaults

    Change the Port value from 8000 to 5005. Leave each of the other properties as is.

  11. Click Apply and then click Debug.
  12. In the JMX Navigator view, double-click Fuse [xxx] [Disconnected] to connect to it, and then expand its tree.
  13. In the Project Explorer view, drag a test message from src/test/resources/data and drop it on the cbr-example-context/Endpoints/file/work/cbr/input folder in the JMX Navigator view.

    When the message hits the first breakpoint that is set in the routing context, the tooling asks you to switch to the Debug perspective:

    DBCnfrmSwitchToDBView
  14. Click Yes.

    RemoteDBPerspOpen

    At this point, you can use any of the Camel debugger’s tools to debug your routing context.

    Note

    In remote debugging sessions, the Console view does not display log output.

    Note

    When one message reaches the end of the routing context, the debugger is suspended. To continue debugging, switch back to the Fuse Integration perspective and drop another message on the input node in the JMX Navigator view. Each time you do so, the tooling asks you to confirm the switch to the Debug perspective.