0 Replies Latest reply on Aug 23, 2010 4:09 PM by Yo Yo

    JBoss ESB 4.8 Quickstarts, and HornetQ

    Yo Yo Newbie

      We're using JBoss AS 5.1, ESB 4.8 and HornetQ (2.1.1) .  HornetQ comes with a bunch of examples for different scenarios, but none for creating a simple ESB project.  JBoss ESB's examples are written for JBoss Messaging.  After sifting through severl posts here and on the HornetQ forums, I got everything working.

       

      So here's what I did, so you, too can convert the JBoss ESB 4.8 HelloWorld Quickstart working with HornetQ, under JBoss 5.

       

      First, Install JBoss AS 5 (I used 5.1.0), JBoss ESB (I used 4.8), and HornetQ (I used 2.1.1), per their respective instuctions.  That's the order to install them in.  I imagine these instuctions will hold if you use different versions, so long as you use the same major revision numbers.  YMMV.  The HornetQ installer will copy the "default" JBoss server installation to "default-with-hornetq".  Your ESB deployables will also be copied (which is why ESB must be installed before the HornetQ installer is run).

       

      The JBoss ESB 4.8 deployables will still be configured for JBoss Messaging, rather than HornetQ.  Specifically we need to change the jbossesb.esb and the jbpm.esb deployables.  Daniel Bevenius' post http://community.jboss.org/message/516322#516322 explains what you need to do.  I'll summarize it here:

       

      1) In default-with-hornetq\deploy\jbossesb.esb, replace jbm-queue-service.xml file with the HornetQ equivalent: hornetq-jms.xml.

      <configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
         <connection-factory name="NettyConnectionFactory">
            <connectors>
               <connector-ref connector-name="netty"/>
            </connectors>
            <entries>
               <entry name="/ConnectionFactory"/>
               <entry name="/XAConnectionFactory"/>
            </entries>
         </connection-factory>
         <connection-factory name="InVMConnectionFactory">
            <connectors>
               <connector-ref connector-name="in-vm"/>
            </connectors>
            <entries>
               <entry name="java:/ConnectionFactory"/>
               <entry name="java:/XAConnectionFactory"/>
            </entries>
         </connection-factory>
         <queue name="DeadMessageQueue">
            <entry name="/queue/DeadMessageQueue"/>
         </queue>
         <queue name="DataCollectorQueue">
            <entry name="/queue/DataCollectorQueue"/>
         </queue>
         <queue name="OperationsCollectorQueue">
            <entry name="/queue/OperationsCollectorQueue"/>
         </queue>
         <queue name="OperationsResultCollectorQueue">
            <entry name="/queue/OperationsResultCollectorQueue"/>
         </queue>
         <queue name="DataCollectorQueue">
            <entry name="/queue/DataCollectorQueue"/>
         </queue>
      </configuration>
      

       

      2) Update default-with-hornetq\deploy\jbossesb.esb\META-INF\deployment.xml to remove the dependencies to the jbm queues.  Replacing the dependencies doesn't seem to work.

       

      3) Add a file containing an empty service definition. For example, add a file called default-with-hornetq\deploy\jbossesb.esb\dummy-service.xml, containing the following:

      <server>
      </server>
      

       

      4) Switching our attention to jbpm.esb, we need need to replace xmldefault-with-hornetq\deploy\jbpm.esb\jbm-queue-service.xml in jbpm.esb with a hornetq-jms.xml (Which is slightly different from the hornetq-jms.xml from jbossesb.esb, so don't just copy that one).

      <configuration xmlns="urn:hornetq"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
      
         <connection-factory name="NettyConnectionFactory">
            <connectors>
               <connector-ref connector-name="netty"/>
            </connectors>
            <entries>
               <entry name="/ConnectionFactory"/>
               <entry name="/XAConnectionFactory"/>
            </entries>
         </connection-factory>
      
         <connection-factory name="InVMConnectionFactory">
            <connectors>
               <connector-ref connector-name="in-vm"/>
            </connectors>
            <entries>
               <entry name="java:/ConnectionFactory"/>
               <entry name="java:/XAConnectionFactory"/>
            </entries>
         </connection-factory>
      
         <queue name="DeadMessageQueue">
            <entry name="/queue/DeadMessageQueue"/>
         </queue>
      
         <queue name="DataCollectorQueue">
            <entry name="/queue/DataCollectorQueue"/>
         </queue>
      
         <queue name="OperationsCollectorQueue">
            <entry name="/queue/OperationsCollectorQueue"/>
         </queue>
      
         <queue name="CallbackQueue">
            <entry name="/queue/CallbackQueue"/>
         </queue>
      
      </configuration>
      

       

      5) Update default-with-hornetq\deploy\jbpm.esb\META-INF\deployment.xml, to remove the dependencies to the jbm queues.  Here's mine:

      <jbossesb-deployment>
        <depends>jboss.esb:deployment=jbossesb.esb</depends>
        <depends>jboss.esb:service=JbpmService</depends>
        <!--<depends>jboss.esb.destination:service=Queue,name=CallbackQueue</depends>-->
      </jbossesb-deployment>

       

      At this point, the JBoss ESB deployables should work with HornetQ.  The next problem is getthing the ESB HelloWorld Quickstart working with HornetQ.

       

      1) In samples\quickstarts\conf\, copy quickstart.properties-example to quickstart.properties.  In that new file, change org.jboss.esb.server.config to point to default-with-hornetq.  The line might be commented-out, so uncomment it, if necessary.

       

      2) In samples\quickstarts\conf\base-build.xml, we need to add the HornetQ client-side jars.  We need to add:

           default-with-hornetq\lib\hornetq-core-client.jar

           default-with-hornetq\lib\hornetq-jms-client.jar

           default-with-hornetq\lib\netty.jar

      The HornetQ documentation also mentions hornetq-transports.jar and jnp-client.jar, but they are not present in HornetQ 2.1.1.

      I don't know Ant, so there's probly a better way to do this...

      Search for the target definition of "classpath-dependencies-as5".  It starts out like this:

                <target name="classpath-dependencies-as5"

      Now look for the "exec-classpath" path definition for classpath-depenencies-as5.  Add a fileset for HornetQ, by adding the following line:

      <fileset dir="<somethingsomething>/default-with-hornetq/lib" includes="hornetq-core-client.jar hornetq-jms-client.jar netty.jar" /> <!-- Required for HornetQ. -->

      where <somethingsomthing> is the path to your server.

       

      3) In samples\quickstarts\helloworld, replace jbm-queue-service.xml file with the HornetQ equivalent: hornetq-jms.xml.  It's contents are:

      <configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
         <connection-factory name="NettyConnectionFactory">
            <connectors>
               <connector-ref connector-name="netty"/>
            </connectors>
            <entries>
               <entry name="/ConnectionFactory"/>
               <entry name="/XAConnectionFactory"/>
            </entries>
         </connection-factory>
         <connection-factory name="InVMConnectionFactory">
            <connectors>
               <connector-ref connector-name="in-vm"/>
            </connectors>
            <entries>
               <entry name="java:/ConnectionFactory"/>
               <entry name="java:/XAConnectionFactory"/>
            </entries>
         </connection-factory> 
      </configuration>
      

       

      4) In samples\quickstarts\helloworld, delete jbmq-queue-service.xml

       

      5) Add a file containing an empty service definition. For example, add a file called samples\quickstarts\dummy-service.xml.

      <server>
      </server>
      

       

      6) Comment-out the 2 queue dependencies in deployment.xml.

       

      7) In samples\quickstarts\helloworldjboss-esb.xml, look for the <providers> section near the top.  Change the <jms-provider> like so:

      <!-- <jms-provider name="JBossMQ" connection-factory="ConnectionFactory"> -->
      <jms-provider name="JBossMessaging" connection-factory="ConnectionFactory" >

       

      8) Now, we've commented out the old JMS queues from deployment.xml, but we still need to define them somewhere.  Ideally, we would put  these in our new samples\quickstarts\helloworld\hornetq-jms.xml.  Unfortunately, for whatever reason, that doesn't work. Maybe the queue is requested before it's built.  That would stand to reason, since queue dependencies are usually handled in deployment.xml, and that's not working for HornetQ queues.  Whatever the reason, we're going to have to put the Quickstart's queues in the hornetq-jms.xml in default-with-hornetq\deploy\hornetq.sar:

        <queue name="quickstart_helloworld_Request_esb">  
          <entry name="/queue/quickstart_helloworld_Request_esb"/>  
        </queue>
        <queue name="quickstart_helloworld_Request_gw">  
          <entry name="/queue/quickstart_helloworld_Request_gw"/>  
        </queue>
      

       

      You should then be able to do an 'ant clean deploy' on the command line.  Once the quickstart is deployed (check the server logs), you can do an 'ant runtest sendesb' to run the JMS and Straight-to-ESB tests.