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.Questo contenuto non è disponibile nella lingua selezionata.
2.3. Working with Camel on EAP Subsystem
Here are some basic examples that describe how the camel subsystem interacts with JBoss EAP configuration files.
2.3.1. Using a Camel Context Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The
CamelContext
represents a single Camel routing rulebase. It contains all the routes of your application. You can have as many CamelContexts as necessary, provided they have different names.
Camel on EAP allows you to:
- define a
CamelContext
as a part of the subsystem definition in thestandalone.xml
anddomain.xml
files - deploy them in a supported deployment artifact that includes the
-camel-context.xml
suffixed file - provide CamelContexts along with their routes via a RouteBuilder and the CDI integration
You can configure a
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
Also, you can consume a defined CamelContext two ways:
CamelContext
as a part of the subsystem definition this way:
- @injected via Camel-CDI
- via JNDI tree
2.3.1.1. Example of a Context and a Route Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The following example, describes a context along with an associated route provided via CDI and a RouteBuilder. It displays an application scoped bean that starts automatically, when you start an application. The
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
@ContextName
annotation provides a specific name to the CamelContext.
2.3.1.2. Configuring Camel Context using CDI Mechanism Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Camel CDI automatically deploys and configures a
CamelContext
bean. After you initialise the CDI container, a CamelContext bean starts and instantiates automatically.
You can inject a
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
CamelContext
bean into the application as:
@Inject @ContextName(cdi-context) private CamelContext context;
@Inject
@ContextName(cdi-context)
private CamelContext context;
2.3.1.3. Configuring Camel Routes using CDI Mechanism Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
After you initialise the CDI container, Apache Camel CDI automatically collects all the RouteBuilder beans in the application, instantiates and add them to the CamelContext bean instance.
For example, you can add a camel route and declare a class in the following way:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
2.3.1.4. Customizing Camel Context Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Apache Camel CDI provides
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
@ContextName
qualifier that allows you to change the name of the default CamelContext bean. For example,
Note
You can use any
CamelContext
class to declare a custom camel context bean.
2.3.1.5. Supporting Multiple CamelContexts Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
You can declare any number of CamelContext beans in your application. The CDI qualifiers declared on these CamelContext beans are used to bind the Camel routes and other Camel primitives to the corresponding Camel contexts.
The CDI qualifiers declared on the CamelContext beans are also used to bind the corresponding Camel primitives. For example:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
2.3.2. Camel Context Deployment Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
You can deploy a camel context to JBoss EAP two ways:
- Use the
-camel-context.xml
suffix as a part of another supported deployment, such as a JAR, WAR, or EAR deploymentThis deployment may contain multiple-camel-context.xml
files. - Use the
-camel-context.xml
suffix in a standaloneXML
file deployment by dropping the file into the EAP deployment directory
A deployed camel context is CDI injectable as:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
@Resource(name = "java:jboss/camel/context/mycontext") CamelContext camelContext;
@Resource(name = "java:jboss/camel/context/mycontext")
CamelContext camelContext;
2.3.3. Hawtio Web Console Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
HawtIO is a web application that runs in a JVM. You can start Hawtio on your machine:
- deploy HawtIO as a WAR file
- add some users to your management and application realms by using the following command: $ bin/add-user.sh
- navigate to the
http://localhost:8080/hawtio
, the HawtIO login page appears - Clickin the top navigation bar to view all the running Camel Contexts
Apache Camel plugin allows you to browse all the running Camel applications in the current JVM. You can also view the following details:
- list of all the running camel applications
- detail information of each Camel Context such as Camel version number, runtime statics
- list of all the routes and their runtime statistics in each camel application
- manage the lifecycle of all camel applications and their routes
- graphical representation of the running routes along with real time metrics
- live tracing and debugging of running routes
- profile the running routes with real time runtime statics
- browse and send messages to camel endpoint
2.3.4. Selecting Components Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
If you add nested component or component-module XML elements, then instead of the default list of Camel components, only the specified elements will be added to your deployment.
For example,
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
2.3.5. Configuring Camel Subsystem Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The Camel subsystem configuration may contain static system routes. However, these routes are started automatically.
2.3.6. Configuring Camel Deployment Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To make changes in the default configuration of your Camel deployment, you can edit either
WEB-INF/jboss-all.xml
or META-INF/jboss-all.xml
configuration file.
Use a jboss-camel XML element within the
jboss-all.xml
file, to control the camel configuration.