Red Hat Training

A Red Hat training course is available for JBoss Enterprise SOA Platform

10.23. Configuring the Camel Gateway

To see all the different transports Camel can handle, please visit the Camel Component list here: http://camel.apache.org/components.html

Note

Different Camel components have different library dependencies. The JBoss Enterprise SOA Platform only contains the camel-core.jar. You will have to add any other dependencies (including other camel-* jars or third party jars) you require into server//deployers/esb.deployer/lib - not your ESB archive. For more information on using non-core Camel components, see http://community.jboss.org/wiki/CamelGatewayUsingNon-coreComponents/.
If you declare the use of the updated (jbossesb-1.3.0.xsd) schema, in your jboss-esb.xml file, you will see a new <camel-provider> section appear under Providers:
<camel-provider name="...">
<camel-bus busid="...">
	<from uri="..."/>
<from uri="..."/>
</camel-bus>
</camel-provider>
The most interesting part is that which is contained within the <camel-bus> element. An unbounded number of <from uri=""/> elements can be added here. Those familiar with the Camel XML configuration should be very comfortable with that element, as it does exactly what it does in the native Camel XML configuration. There is also a new <camel-gateway> element, which can reference the bus via the busidref attribute:
<camel-gateway name="..." busidref="..."/>
It is possible to define <from uri=""/> elements under the <camel-gateway> element, without using a <camel-provider> at all:
<camel-gateway name="...">
<from uri=""/>
<from uri=""/>
</camel-gateway>
There is also a short-hand mechanism, where you can specify one Camel "from" URI as an XML attribute at either the gateway level or at the bus level. Here is the gateway level:
<camel-gateway name="..." from-uri="..."/>
Now here is the bus level:
<camel-bus name="..." busid="..." from-uri="..."/>

Note

It is important to understand that all Camel "from" URIs defined at both the <camel-bus> and <camel-gateway> level are cumulative, whether you use the element form and/or the short-hand form.
At this point, you might wonder where the <to uri=””/> elements are, because in Camel you need to define at least one destination. In the JBoss Enterprise Service Bus, every Camel "from" URI translates to one route (added to all other routes in that gateway+bus), with an implicit Camel “to” URI which invokes the associated Service where you are assigning the <camel-gateway>. Under-the-hood, all routes in that gateway+bus will end up invoking that service, and they are all run within the same CamelContext, whose lifecycle is tied to that CamelGateway's lifeycle.

Note

It is important to be aware of the fact that this gateway only supports Camel routes that can be defined in a single "from" URI. The basic stanza supported by the gateway is from(endpointUri).to(esbService). The gateway does not support routes that would require intermediate routing to other Camel components.

Note

It is important to be aware of the fact that this gateway only supports Camel routes that can be defined in a single "from" URI. The basic stanza supported by the gateway is from(endpointUri).to(esbService). The gateway does not support routes that would require intermediate routing to other Camel components.
Some Camel components perform scheduled routing tasks, for example the HTTP component can be used to periodically poll a HTTP address, or the File component can poll a filesystem directory. Not all of these components support a URI option for configuring the poll frequency. The HTTP component is one such example. In these cases, you just need to prefix the component URI Scheme with "esbschedule:<frequency-in-millis>" (for example, . <from uri="esbschedule:5000:http://www.jboss.org" /> would poll jboss.org every five seconds.)
Finally, there are two other optional attributes that one can place at either the <camel-gateway> or <camel-bus> level (the gateway overriding the bus in these cases): async and timeout:
<camel-gateway name="..." from-uri="..." async="false" timeout="30000"/>
  • The async attribute (defaults to “false”) says whether the underlying ServiceInvoker should invoke the associated Service synchronously or asynchronously.
  • The timeout attribute (defaults to “30000”), defines how many milliseconds the ServiceInvoker should wait on a synchronous invocation before giving up.

Note

For more detailed information, please visit this wiki page: http://community.jboss.org/wiki/CamelGateway
You can also study the camel_helloworld quick start.