Este contenido no está disponible en el idioma seleccionado.
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 Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
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
CamelContextas a part of the subsystem definition in thestandalone.xmlanddomain.xmlfiles - deploy them in a supported deployment artifact that includes the
-camel-context.xmlsuffixed 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 Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
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 Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
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 Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
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 Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
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 Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
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 Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
You can deploy a camel context to JBoss EAP two ways:
- Use the
-camel-context.xmlsuffix as a part of another supported deployment, such as a JAR, WAR, or EAR deploymentThis deployment may contain multiple-camel-context.xmlfiles. - Use the
-camel-context.xmlsuffix in a standaloneXMLfile 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 Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
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 - Click in 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 Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
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 Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
The Camel subsystem configuration may contain static system routes. However, these routes are started automatically.
2.3.6. Configuring Camel Deployment Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
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.