Chapter 11. Deploying using a JMS broker
Abstract
Fuse 7.0 does not ship with a default internal broker, but it is designed to interface with four external JMS brokers.
Fuse 7.0 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.0.
11.1. AMQ 7 quickstart Copy linkLink copied to clipboard!
A quickstart is provided to demonstrate the set up and deployment of apps using the AMQ 7 broker.
Setup the quickstart
-
Navigate to
FUSE_HOME/quickstarts/beginner/camel-jms
-
Enter
mvn clean install
to build the quickstart. -
Copy the file
org.ops4j.connectionfactory-amq7.cfg
fromFUSE_HOME/quickstarts/beginner/camel-jms/src/main
directory to theFUSE_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. -
Start Fuse by running
./bin/fuse
on Linux orbin\fuse.bat
on Windows. 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}
feature:install pax-jms-pool artemis-jms-client camel-blueprint camel-jms install -s mvn:org.jboss.fuse.quickstarts/camel-jms/${project.version}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Fuse will give you a bundle ID when the bundle is deployed.
-
Enter
log:display
to see the start up log information. Check to make sure the bundle was deployed successfully.
Run the quickstart
-
When the Camel routes run the
FUSE_HOME/quickstarts/beginner/camel-jms/work/jms/input
directory will be created. Copy the files from theFUSE_HOME/quickstarts/beginner/camel-jms/src/main/data
directory to theFUSE_HOME/quickstarts/beginner/camel-jms/work/jms/input
directory. The files copied into the
…/src/main/data
file are order files. Wait for a minute and then check theFUSE_HOME/quickstarts/beginner/camel-jms/work/jms/output
directory. The files will be sorted into separate directories according to their country of destination:-
order1.xml
,order2.xml
andorder4.xml
inFUSE_HOME/quickstarts/beginner/camel-jms/work/jms/output/others/
-
order3.xml
andorder5.xml
inFUSE_HOME/quickstarts/beginner/camel-jms/work/jms/output/us
-
order6.xml
inFUSE_HOME/quickstarts/beginner/camel-jms/work/jms/output/fr
-
-
Use
log:display
to see the log messages:
Receiving order order1.xml Sending order order1.xml to another country Done processing order1.xml
Receiving order order1.xml
Sending order order1.xml to another country
Done processing order1.xml
- 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
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
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:
11.2. Using the Artemis core client Copy linkLink copied to clipboard!
The Artemis core client can be used to connect to an external broker instead of qpid-jms-client
.
Connect using the Artemis core client
-
To enable the Artemis core client, start Fuse. Navigate to the
FUSE_HOME
directory and enter./bin/fuse
on Linux orbin\fuse.bat
on Windows. -
Add the Artemis client as a feature using the following command:
feature:install artemis-core-client
- 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;
import org.apache.qpid.jms.JmsConnectionFactory;
Set up the connection:
ConnectionFactory connectionFactory = new JmsConnectionFactory("amqp://localhost:5672"); try (Connection connection = connectionFactory.createConnection()) {
ConnectionFactory connectionFactory = new JmsConnectionFactory("amqp://localhost:5672");
try (Connection connection = connectionFactory.createConnection()) {