Version 15

    First, please familiarize yourself with the CamelGateway.


    The CamelGateway functionality provided in JBossESB 4.9 ships with minimal dependencies.  In fact, the only Camel library that is included by default is camel-core.  The Components provided in that library will work out-of-the-box, and are referenced via URI in your .esb archive's jboss-esb.xml file, as described CamelGateway.


    If you would like to use Camel Components that are not included in camel-core, then you will have to add the appropriate library dependencies yourself.  Specifically, the camel-xxx jar that contains the Component, and any required third-party jars.


    The breakingwoods project pioneered the idea of integrating Camel and JBossESB, and in one example leveraged the ability for Camel to "watch" an IRC chat room and trigger processing based on IRC events.  We will similarly go through a simple IRC example here, except now leveraging the CamelGateway.


    First a look at jboss-esb.xml:


    <jbossesb xmlns="" parameterReloadSecs="5">
            <service category="camel_irc" name="service1" description="IRC Test" invmScope="GLOBAL">
                    <camel-gateway name="gateway1" from-uri="irc://"/>
                    <action name="action1" class="org.jboss.soa.esb.actions.SystemPrintln"/>


    The only interesting part is the from-uri attribute on the camel-gateway element.  That URI means Camel will join the #cameltest room as "jbossesb" on  Any events in the chat room will be noticed by Camel, handed to the ESB, and will cause those events to be outputted to the server log via the SystemPrintln action defined in the service.


    Before you can deploy the ESB archive containing that jboss-esb.xml file you will have to add the required libraries.  They are:


    1. camel-irc-2.4.0.jar   
    2. irclib.jar   


    Both camel-irc-2.4.0.jar and irclib.jar have to be put in a place available to JBossESB classloading.  Depending if you are running JBossESB on JBoss AS 4 or 5, the location will differ:


    • AS 4: .../server/default/deploy/jbossesb.sar/lib/
    • AS 5: .../server/default/deployers/esb.deployer/lib/


    Note: When installing additional Camel Components, the directories listed above are the recommended location for the Component jar libraries and any of their dependent jar libraries.  Whereas installing these libraries in other directories available to JBoss might be possible, it has not been tested, and thus not recommended.  Finally, be aware that a restart of the ESB server will be required afer installing the Component jars before the Component's URI can be used by the CamelGateway.


    Now you can safely deploy the ESB archive, which will produce the following output in your server log (if INFO and DEBUG log4j levels are enabled):


    10:07:07,308 INFO  [JBoss4ESBDeployer] create esb service, Quickstart_camel_helloworld.esb
    10:07:07,483 DEBUG [CamelGateway] adding routes [
    <routes xmlns="">
        <from uri="irc://"/>
        <to uri="jbossesb://service?category=camel_irc&name=service1&async=false&timeout=30000"/>
    10:07:07,938 INFO  [DefaultCamelContext] Apache Camel 2.4.0 (CamelContext: camel-1) is starting
    10:07:07,938 INFO  [DefaultCamelContext] JMX is disabled. Using DefaultManagementStrategy.
    10:07:08,515 INFO  [AnnotationTypeConverterLoader] Found 3 packages with 13 @Converter classes to load
    10:07:08,568 INFO  [DefaultTypeConverter] Loaded 143 type converters in 0.587 seconds
    10:07:08,871 INFO  [DefaultCamelContext] Route: route1 started and consuming from: Endpoint[irc://]
    10:07:08,871 INFO  [DefaultCamelContext] Started 1 routes
    10:07:08,871 INFO  [DefaultCamelContext] Apache Camel 2.4.0 (CamelContext: camel-1) started in 0.933 seconds
    10:07:21,268 INFO  [STDOUT] Message structure: 
    10:07:21,268 INFO  [STDOUT] [VERSION].
    10:07:21,896 INFO  [STDOUT] Message structure: 
    10:07:21,896 INFO  [STDOUT] [JOIN].
    10:07:22,008 INFO  [STDOUT] Message structure: 
    10:07:22,008 INFO  [STDOUT] [+ns ].


    Next, I log into the chatroom myself:



    You can see that now both jbossesb and myself are in the same chat room.  This event will trigger the following output in the server log:


    10:08:09,415 INFO  [STDOUT] Message structure: 
    10:08:09,415 INFO  [STDOUT] [JOIN].


    Next, I will type the obligatory "Hello world!" into the chat window:




    This event will trigger the following output in the server log:


    10:09:27,494 INFO  [STDOUT] Message structure: 
    10:09:27,494 INFO  [STDOUT] [Hello world!].


    I then exit the chat room, triggering the following output in the server log:


    10:10:09,089 INFO  [STDOUT] Message structure: 
    10:10:09,089 INFO  [STDOUT] [].


    I then undeploy the ESB archive containing the service, which finally produces the following output in the server log:


    10:10:34,267 INFO  [DefaultCamelContext] Apache Camel 2.4.0 (CamelContext:camel-1) is shutting down
    10:10:34,268 INFO  [DefaultShutdownStrategy] Starting to graceful shutdown 1 routes (timeout 300 seconds)
    10:10:34,310 INFO  [DefaultShutdownStrategy] Route: route1 shutdown complete, was consuming from: Endpoint[irc://]
    10:10:34,310 INFO  [DefaultShutdownStrategy] Graceful shutdown of 1 routes completed in 0 seconds
    10:10:34,311 INFO  [DefaultInflightRepository] Shutting down with no inflight exchanges.
    10:10:34,311 INFO  [DefaultCamelContext] Uptime: 3 minutes
    10:10:34,311 INFO  [DefaultCamelContext] Apache Camel 2.4.0 (CamelContext: camel-1) is shutdown in 0.044 seconds
    10:10:34,377 WARN  [ServiceMessageCounterLifecycleResource] Calling cleanup on existing service message counters for identity ID-7


    That's it!


    Using other Camel Components should be just as straightforward: Just add the Component jar, any third-party jars, reference the Component via URI in jboss-esb.xml, and deploy.


    Questions?  Feel free to ask in the JBossESB User Forum.