Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.5.2. Examples of JBoss Fuse on EAP
This section includes the working examples that demonstrate various features of JBoss on Fuse EAP. These examples will help you get started with the EAP Camel subsystem.
Note
You can access the
$JBOSS_HOME/quickstarts/camel
directory to view the full source code of all the examples.
To run the given examples, ensure that you install the following on your machine:
- Maven 3.2.3 or greater
- Java 1.7 or greater
- Red Hat JBoss Fuse 6.3
- Red Hat JBoss EAP 6.4
Note
To install JBoss Fuse on EAP, see chapter "Install JBoss Fuse on JBoss EAP" in "Installation on JBoss EAP".
5.2.1. Camel ActiveMQ Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The following example describes how to use the
camel-activemq
component with JBoss Fuse on EAP, to produce and consume JMS messages.
In this example, a camel route consumes files from the
${JBOSS_HOME}/standalone/data/orders
directory and place the content to an external ActiveMQ JMS queue. A second route consumes messages from the OrdersQueue and then via a content based router, it sorts the directory of each country that are located within the $JBOSS_HOME/standalone/data/orders/processed
directory.
Note
The CLI script automatically configure the ActiveMQ resource adapter. These scripts are located within the
src/main/resources/cli
directory.
5.2.1.1. Running the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Before you start running the application, make sure that the following are installed on your machine:
- Maven 3.2.3 or greater
- JBoss Fuse on EAP
- An ActiveMQ broker
Procedure 5.1. To run the application
Perform the following steps:
- Start the application server in standalone mode.
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the following command to build and deploy the project.
mvn install -Pdeploy
mvn install -Pdeploy
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2.1.2. Configuring ActiveMQ Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Here are the details to configure the ActiveMQ component:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
5.2.1.3. Undeploy the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Run the following command to undeploy the application:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
It removes the ActiveMQ resource adapter configuration. However, you need to restart the application after you execute the undeploy command.
mvn clean -Pdeploy
mvn clean -Pdeploy
5.2.2. Camel CDI Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The following example describes how to use the
camel-cdi
component with JBoss Fuse on EAP, to integrate CDI beans with camel routes.
In this example, a camel route takes a message payload from a servlet HTTP GET request and passes it to the direct endpoint. However, you can pass the payload to a Camel CDI bean invocation to produce a message response. It displays the message response on the web browser page.
5.2.2.1. Running the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Before you start running the application, make sure that the following are installed on your machine:
- Maven 3.2.3 or greater
- JBoss Fuse on EAP
Procedure 5.2. To run the application
Perform the following steps:
- Start the application server in standalone mode.
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the following command to build and deploy the project.
mvn install -Pdeploy
mvn install -Pdeploy
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2.2.2. Configuring Camel CDI Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Here are the details to configure the
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
camel-cdi
component:
5.2.2.3. Undeploy the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Run the following command to undeploy the application:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
mvn clean -Pdeploy
mvn clean -Pdeploy
5.2.3. Camel JMS Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The following example describes how to use the
camel-jms
component with JBoss Fuse on EAP to produce and consume JMS messages.
In this example, a Camel route consumes files from the
${JBOSS_HOME}/standalone/data/orders
directory and place the content in the OrdersQueue. A second route consumes messages from the OrdersQueue and through a content based router.
5.2.3.1. Running the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Before you start running the application, make sure that the following are installed on your machine:
- Maven 3.2.3 or greater
- JBoss Fuse on EAP
Procedure 5.3. To run the application
Perform the following steps:
- Start the application server in standalone mode.
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the following command to build and deploy the project.
mvn install -Pdeploy
mvn install -Pdeploy
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2.3.2. Configuring Camel JMS Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Here are the details to configure the camel-jms component.
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
5.2.3.3. Undeploy the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Run the following command to undeploy the application:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
mvn clean -Pdeploy
mvn clean -Pdeploy
5.2.4. Camel JPA Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The following example describes how to use the
camel-jpa
component with JBoss Fuse on EAP to persist entities to the in-memory database.
In this example, a camel route consumes XML files from the
${JBOSS_HOME}/standalone/data/customers
directory. Camel then uses JAXB to unmarshal the data to a Customer entity. However, the entity is then passed to the JPA endpoint and is persisted to the customer database.
5.2.4.1. Running the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Before you start running the application, make sure that the following are installed on your machine:
- Maven 3.2.3 or greater
- JBoss Fuse on EAP
Procedure 5.4. To run the application
Perform the following steps:
- Start the application server in standalone mode.
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the following command to build and deploy the project.
mvn install -Pdeploy
mvn install -Pdeploy
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2.4.2. Configuring Camel JPA Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Here are the details to configure the
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
camel-jpa
component.
5.2.4.3. Undeploy the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Run the following command to undeploy the application:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
mvn clean -Pdeploy
mvn clean -Pdeploy
5.2.5. Camel Mail Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The following example describes how to use the
camel-mail
component with JBoss Fuse on EAP to send and receive email.
In this example, you can configure a local mail server on your machine. This eliminates the need to use any external mail services. You can access the
src/main/resources/cli
directory to see the EAP mail subsystem configuration.
Note
Here the mail session used is bound to JNDI at the
java:jboss/mail/
location. You can configure the server entries for SMTP and POP3 protocols.
5.2.5.1. Running the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Before you start running the application, make sure that the following are installed on your machine:
- Maven 3.2.3 or greater
- JBoss Fuse on EAP
Procedure 5.5. To run the application
Perform the following steps:
- Start the application server in standalone mode.
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the following command to build and deploy the project.
mvn install -Pdeploy
mvn install -Pdeploy
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
If you want to deploy the application multiple times, ensure that you run the undeploy command and restart the application server.
5.2.5.2. Configuring Camel Mail Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Here are the configurations details to configure the
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
camel-mail
component.
5.2.5.3. Undeploy the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Run the following command to undeploy the application:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
mvn clean -Pdeploy
mvn clean -Pdeploy
5.2.6. Camel REST Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The following example describes how to write the JAX-RS REST routes with JBoss Fuse on EAP.
It includes two methods of implementing Camel REST consumers. Requests made to paths under the
/example-camel-rest/camel
are handled by the Camel REST DSL and requests made to paths >/example-camel-rest/rest
are handled by the EAP JAX-RS subsystem along with the CamelProxy.
5.2.6.1. Running the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Before you start running the application, make sure that the following are installed on your machine:
- Maven 3.2.3 or greater
- JBoss Fuse on EAP
Procedure 5.6. To run the application
Perform the following steps:
- Start the application server in standalone mode.
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the following command to build and deploy the project.
mvn install -Pdeploy
mvn install -Pdeploy
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2.6.2. Configuring Camel REST Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Here are the configurations details to configure the Camel REST routes.
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
5.2.6.3. Undeploy the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Run the following command to undeploy the application:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
mvn clean -Pdeploy
mvn clean -Pdeploy
5.2.7. Camel Transacted JMS Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The following example describes how to use the
camel-jms
component with JBoss Fuse on EAP to produce and consume JMS messages in a transacted session.
In this example, a camel route consumes files from the
${JBOSS_HOME}/standalone/data/orders
directory and place the content in the OrdersQueue. A second route consumes messages from the OrdersQueue, converts the message body to the Order entity and persists it.
5.2.7.1. Running the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Before you start running the application, make sure that the following are installed on your machine:
- Maven 3.2.3 or greater
- JBoss Fuse on EAP
Procedure 5.7. To run the application
Perform the following steps:
- Start the application server in standalone mode.
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
${JBOSS_HOME}/bin/standalone.sh -c standalone-full.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the following command to build and deploy the project.
mvn install -Pdeploy
mvn install -Pdeploy
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - When the server starts, navigate to the
example-camel-transacted-jms/orders
directory.
The application displays the
page. It includes the list of processed orders.
5.2.7.2. Configuring Transacted JMS Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Here are the details to configure the
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
camel-jms
component in a transacted session.
5.2.7.3. Undeploy the Application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Run the following command to undeploy the application:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
mvn clean -Pdeploy
mvn clean -Pdeploy