Questo contenuto non è disponibile nella lingua selezionata.
Chapter 13. Deploying using a JMS broker
Abstract
Fuse 7.8 does not ship with a default internal broker, but it is designed to interface with four external JMS brokers.
Fuse 7.8 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.8.
13.1. AMQ 7 quickstart Copia collegamentoCollegamento copiato negli appunti!
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
-
Navigate to the
quickstarts/camel/camel-jmsfolder. -
Enter
mvn clean installto build the quickstart. -
Copy the file
org.ops4j.connectionfactory-amq7.cfgfrom the/camel/camel-jms/src/maindirectory to theFUSE_HOME/etcdirectory 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/fuseon Linux orbin\fuse.baton 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:displayto see the start up log information. Check to make sure the bundle was deployed successfully.
Run the quickstart
-
When the Camel routes run, the
/camel/camel-jms/work/jms/inputdirectory will be created. Copy the files from the/camel/camel-jms/src/main/datadirectory to the/camel/camel-jms/work/jms/inputdirectory. The files copied into the
…/src/main/datafile are order files. Wait for a minute and then check the/camel/camel-jms/work/jms/outputdirectory. The files will be sorted into separate directories according to their country of destination:-
order1.xml,order2.xmlandorder4.xmlin/camel/camel-jms/work/jms/output/others/ -
order3.xmlandorder5.xmlin/camel/camel-jms/work/jms/output/us -
order6.xmlin/camel/camel-jms/work/jms/output/fr
-
-
Use
log:displayto 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:
13.2. Using the Artemis core client Copia collegamentoCollegamento copiato negli appunti!
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_HOMEdirectory and enter./bin/fuseon Linux orbin\fuse.baton 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()) {