LibraryToggle FramesPrintFeedback

In order to run the sample router application, you need to have the camel-activemq feature installed in the OSGi container. The camel-activemq component is needed for defining Fuse Message Broker-based JMS endpoints in Fuse Mediation Router. This feature is not installed by default, so you must install it using the following console command:

karaf@root> features:install camel-activemq

You also need the activemq feature, but this feature is normally available, because Fuse ESB installs it by default.

[Tip]Tip

Most of the Fuse Mediation Router components are not installed by default. Whenever you are about to define an endpoint in a Fuse Mediation Router route, remember to check whether the corresponding component feature is installed. Fuse Mediation Router component features generally have the same name as the corresponding Fuse Mediation Router component artifact ID, camel-ComponentName.

Example 9.1 gives an example of a Fuse Mediation Router route defined using the Spring XML DSL. Messages generated by the timer endpoint are propagated through the JMS broker and then written out to the file system.


Example 9.1 defines two routes, as follows:

  1. The first route uses a timer endpoint to generate messages at four-second intervals. The setBody element places a dummy string in the body of the message (which would otherwise be null). The messages are then sent to the camel.timer queue on the broker (the activemq:camel.timer endpoint).

    [Note]Note

    The activemq scheme in activemq:camel.timer is resolved by looking up activemq in the bean registry, which resolves to the locally instantiated bean with ID, activemq.

  2. The second route pulls messages off the camel.timer queue and then writes the messages to the specified directory, C:\temp\sandpit\timer, in the file system.

To run the sample router application, perform the following steps:

  1. Using your favorite text editor, copy and paste the router configuration from Example 9.1 into a file called camel-timer.xml.

    Edit the file endpoint in the second route, in order to change the target directory to a suitable location on your file system:

        <route>
          <from uri="activemq:camel.timer"/>
          <to uri="file:YourDirectoryHere!"/>
        </route>
  2. Start up a local instance of the Fuse ESB runtime by entering the following at a command prompt:

    servicemix
  3. Make sure the requisite features are installed in the OSGi container. To install the camel-activemq feature, enter the following command at the console:

    karaf@root> features:install camel-activemq

    To ensure that the activemq-broker feature is not installed, enter the following command at the console:

    karaf@root> features:uninstall activemq-broker
  4. Use one of the following alternatives to obtain a broker instance for this demonstration:

    • Use the default broker—assuming you have not disabled the default broker, you can use it for this demonstration, because it is listening on the correct port, 61616.

    • Create a new broker instance using the console—if you prefer not to use the default broker, you can disable it (as described in The Default Broker) and then create a new JMS broker instance by entering the following command at the console:

      karaf@root> activemq:create-broker --name test

      After executing this command, you should see the broker configuration file, test-broker.xml, in the InstallDir/deploy directory.

  5. Hot deploy the router configuration you created in step 1. Copy the camel-timer.xml file into the InstallDir/deploy directory.

  6. Within a few seconds, you should start to see files appearing in the target directory (which is C:\temp\sandpit\timer, by default). The file component automatically generates a unique filename for each message that it writes.

    It is also possible to monitor activity in the JMS broker by connecting to the Fuse ESB runtime's JMX port. To monitor the broker using JMX, perform the following steps:

    1. To monitor the Fuse ESB runtime, start a JConsole instance (a standard Java utility) by entering the following command:

      jconsole
    2. Initially, a JConsole: Connect to Agent dialog prompts you to connect to a JMX port. From the Local tab, select the org.apache.felix.karaf.main.Bootstrap entry and click Connect.

    3. In the main JConsole window, click on the MBeans tab and then drill down to org.apache.activemq|test|Queue in the MBean tree (assuming that test is the name of your broker).

    4. Under the Queue folder, you should see the camel.timer queue. Click on the camel.timer queue to view statistics on the message throughput of this queue.

  7. To shut down the router application, delete the camel-timer.xml file from the InstallDir/deploy directory.

Comments powered by Disqus
loading table of contents...