Chapter 13. Deploying using a JMS broker


Abstract

Fuse 7.13 does not ship with a default internal broker, but it is designed to interface with four external JMS brokers.

Fuse 7.13 containers contain broker client libraries for the supported external brokers.

See Supported Configurations for more information about the external brokers, client and Camel component combinations that are available for messaging on Fuse 7.13.

13.1. AMQ 7 quickstart

A quickstart is provided to demonstrate the set up and deployment of apps using the AMQ 7 broker.

Download the quickstart

You can install all of the quickstarts from the Fuse Software Downloads page.

Extract the contents of the downloaded zip file to a local folder, for example, a folder named quickstarts.

Setup the quickstart

  1. Navigate to the quickstarts/camel/camel-jms folder.
  2. Enter mvn clean install to build the quickstart.
  3. Copy the file org.ops4j.connectionfactory-amq7.cfg from the /camel/camel-jms/src/main directory to the FUSE_HOME/etc directory in your Fuse installation. Verify its contents for the correct broker URL and credentials. By default, the broker URL is set to tcp://localhost:61616 following AMQ 7’s CORE protocol. Credentials are set to admin/admin. Change these details to suit your external broker.
  4. Start Fuse by running ./bin/fuse on Linux or bin\fuse.bat on Windows.
  5. In the Fuse console, enter the following commands:

    feature:install pax-jms-pool artemis-jms-client camel-blueprint camel-jms
    
    install -s mvn:org.jboss.fuse.quickstarts/camel-jms/${project.version}

    Fuse will give you a bundle ID when the bundle is deployed.

  6. Enter log:display to see the start up log information. Check to make sure the bundle was deployed successfully.
12:13:50.445 INFO [Blueprint Event Dispatcher: 1] Attempting to start Camel Context jms-example-context
12:13:50.446 INFO [Blueprint Event Dispatcher: 1] Apache Camel 2.21.0.fuse-000030 (CamelContext: jms-example-context) is starting
12:13:50.446 INFO [Blueprint Event Dispatcher: 1] JMX is enabled
12:13:50.528 INFO [Blueprint Event Dispatcher: 1] StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
12:13:50.553 INFO [Blueprint Event Dispatcher: 1] Route: file-to-jms-route started and consuming from: file://work/jms/input
12:13:50.555 INFO [Blueprint Event Dispatcher: 1] Route: jms-cbr-route started and consuming from: jms://queue:incomingOrders?transacted=true
12:13:50.556 INFO [Blueprint Event Dispatcher: 1] Total 2 routes, of which 2 are started

Run the quickstart

  1. When the Camel routes run, the /camel/camel-jms/work/jms/input directory will be created. Copy the files from the /camel/camel-jms/src/main/data directory to the /camel/camel-jms/work/jms/input directory.
  2. The files copied into the …​/src/main/data file are order files. Wait for a minute and then check the /camel/camel-jms/work/jms/output directory. The files will be sorted into separate directories according to their country of destination:

    • order1.xml, order2.xml and order4.xml in /camel/camel-jms/work/jms/output/others/
    • order3.xml and order5.xml in /camel/camel-jms/work/jms/output/us
    • order6.xml in /camel/camel-jms/work/jms/output/fr
  3. Use log:display to see the log messages:
Receiving order order1.xml
Sending order order1.xml to another country
Done processing order1.xml
  1. Camel commands will show details about the context:

Use camel:context-list to show the context details:

Context               Status              Total #       Failed #     Inflight #   Uptime
-------               ------              -------       --------     ----------   ------
jms-example-context   Started                  12              0              0   3 minutes

Use camel:route-list to display the Camel routes in the context:

Context               Route               Status              Total #       Failed #     Inflight #   Uptime
-------               -----               ------              -------       --------     ----------   ------
jms-example-context   file-to-jms-route   Started                   6              0              0   3 minutes
jms-example-context   jms-cbr-route       Started                   6              0              0   3 minutes

Use camel:route-info to display the exchange statistics:

karaf@root()> camel:route-info jms-cbr-route jms-example-context
Camel Route jms-cbr-route
    Camel Context: jms-example-context
    State: Started
    State: Started

Statistics
    Exchanges Total: 6
    Exchanges Completed: 6
    Exchanges Failed: 0
    Exchanges Inflight: 0
    Min Processing Time: 2 ms
    Max Processing Time: 12 ms
    Mean Processing Time: 4 ms
    Total Processing Time: 29 ms
    Last Processing Time: 4 ms
    Delta Processing Time: 1 ms
    Start Statistics Date: 2018-01-30 12:13:50
    Reset Statistics Date: 2018-01-30 12:13:50
    First Exchange Date: 2018-01-30 12:19:47
    Last Exchange Date: 2018-01-30 12:19:47

13.2. Using the Artemis core client

The Artemis core client can be used to connect to an external broker instead of qpid-jms-client.

Connect using the Artemis core client

  1. To enable the Artemis core client, start Fuse. Navigate to the FUSE_HOME directory and enter ./bin/fuse on Linux or bin\fuse.bat on Windows.
  2. Add the Artemis client as a feature using the following command: feature:install artemis-core-client
  3. When you are writing your code you need to connect the Camel component with the connection factory.

Import the connection factory:

import org.apache.qpid.jms.JmsConnectionFactory;

Set up the connection:

ConnectionFactory connectionFactory = new JmsConnectionFactory("amqp://localhost:5672");
      try (Connection connection = connectionFactory.createConnection()) {
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.