10 Replies Latest reply on Jan 26, 2011 12:36 AM by noelo

    Consuming messages from a remote HornetQ node

    noelo

      Hi,

      I'm trying to configure a service on a SOA-P 5 instance to consume messages from a gateway queue hosted on a remote HornetQ (v2.1.1 final). The SOA-P instance is using JBM for its internal JMS queues.

      When using the JMS provider it all works ok but I want to use the jms-jca-provider.

       

      I've copied the hornetq-ra.rar into the server/deploy directory and configured the providerloader and service as below but I still receive no messages onto the gateway queue.

      The hornetQ server is a standalone instance (not embedded in an AS instance) running on the same box and providing JNDI access on port 3099.

       

      Nothing of interest is appearing in the logs.

       

      Can someone please take a look at the config. I'm sure its a SOA-P configuration issue its just I'm not sure where its misconfigured.

       

      I have configured and deployed a hq-jms-ds.xml with the following:

      {code}

       

      <?xml version="1.0" encoding="UTF-8"?>
      <connection-factories> 
         
          <mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="hornetq:service=JMSProviderLoader,name=JMSProvider">
               <attribute name="ProviderName">HornetQJMSProvider</attribute>
               <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
               <attribute name="FactoryRef">XAConnectionFactory</attribute>
               <attribute name="QueueFactoryRef">XAConnectionFactory</attribute>
               <attribute name="TopicFactoryRef">XAConnectionFactory</attribute>
                 <attribute name="Properties">
      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=jnp://localhost:3099
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      </attribute>
         </mbean>
         <tx-connection-factory>
            <jndi-name>HJmsXA</jndi-name>
            <xa-transaction/>
            <rar-name>hornetq-ra.rar</rar-name>
            <connection-definition>org.hornetq.ra.HornetQRAConnectionFactory</connection-definition>
            <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Queue</config-property>
            <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/HornetQJMSProvider</config-property>
            <max-pool-size>20</max-pool-size>
            <security-domain-and-application>JmsXARealm</security-domain-and-application>
            <config-property name="ConnectionParameters" type="java.lang.String">host=localhost;port=5445</config-property>
         </tx-connection-factory>
      </connection-factories>
      {code}
      And the service is as follows:
      {code}
      <?xml version = "1.0" encoding = "UTF-8"?>
      <providers>
           <jms-jca-provider name="HornetQ" connection-factory="XAConnectionFactory"
                jndi-URL="jnp://localhost:3099"
                jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
                java.naming.factory.url.pkgs="org.jboss.naming:org.jnp.interfaces"
                providerAdapterJNDI="java:/HornetQJMSProvider">
                <jms-bus busid="quickstartGwChannel">
                     <jms-message-filter
                          dest-type="QUEUE" dest-name="queue/quickstart_jms_transacted_Request_gw" transacted="true"/>
                </jms-bus>
           </jms-jca-provider>
           <jms-provider name="JBossMessaging" connection-factory="ConnectionFactory">   
                <jms-bus busid="quickstartEsbChannel">
                     <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_jms_transacted_Request_esb"/>
                </jms-bus>
           </jms-provider>
      </providers>
              <services>
                      <service
                              category="JMSSecuredESB"
                              name="SimpleListener"
                              description="JMS Secured quickstart sample">
                              <listeners>
                                      <jms-listener name="JMS-Gateway"
                                              busidref="quickstartGwChannel"
                                              is-gateway="true"/>
                                      <jms-listener name="jmssecured"
                                              busidref="quickstartEsbChannel"/>
                              </listeners>
                              <actions mep="OneWay">
                                      <action name="printMessage" class="org.jboss.soa.esb.actions.SystemPrintln">
                                              <property name="message" value="JMS Transacted Quickstart entered. Message body"/>
                                              <property name="printfull" value="false"/>
                                      </action>
                              </actions>
                      </service>
              </services>
      </jbossesb>
      {code}
      The hornetq jms queues are defined as
      {code}
              <queue name="quickstart_jms_transacted_Request_gw">
                      <entry name="/queue/quickstart_jms_transacted_Request_gw"/>
              </queue>
      {code}
        • 1. Re: Consuming messages from a remote HornetQ node
          tfennelly

          Hey Noel.... you've manually tried connecting to (and using) the hornetq destinations via the configured <connection-factories>?  i.e. leaving the esb out of the equation for now.

          • 2. Re: Consuming messages from a remote HornetQ node
            noelo

            Hi Tom,

            I deployed a MDB on the ESB instance and this can pickup the messages from the queue.

            I have turned on debug logs on the HornetQ instance and I can see the ESB connecting to the HQ server but no messages are received at the ESB.

             

            I have attached debug server logs showing the following

            1. Deployed the ESB
            2. Send 2 messages to the remoteQ
            3. Deployed the MDB
            4. 2 messages processed from the remoteQ by the MDB (look for the line "it works" in the logs)

             

            Just to confirm what I've got deployed

            1. A hornetq server running on a remote node with the queue configured and running JNDI
            2. Hornetq-ra.rar with the ra.xml configured to point to the remote server
            3. hq-jms-ds.xml with the JNDI details of the remote hornetQ server
            4. The hornetq libs deployed into the server/lib directory
            5. Both the SOA-P instance and the HornetQ server are running on a real address i.e. not localhost and the firewalls are correct.

             

            I've tried to add the adapter attribute to the jms-jca element but the deployer then complains about a missing activation spec on deployment.

             

            Any ideas of anything else I can try..

             

            regards

            Noel

            • 3. Re: Consuming messages from a remote HornetQ node
              noelo

              I finally figured this out. There hornet-ra.rar needs an activation mapper implementation before it can be used correctly.

              This is added by specifying the jcaActivationMapper.

               

               

              {code:xml}

              <jms-jca-provider name="HornetQ"

                   connection-factory="ConnectionFactory"

                   adapter="hornetq-ra.rar"

                   providerAdapterJNDI="java:/HornetQJMSProvider">

                   <property name="jcaActivationMapper" value="org.jboss.soa.esb.listeners.jca.JBossActivationMapper"/>

                   <jms-bus busid="quickstartGwChannel">

                   <jms-message-filter

                   dest-type="QUEUE"

                   dest-name="queue/quickstart_jms_transacted_Request_gw" transacted="false"/>

                   </jms-bus>

              .

              .

              </jms-jca-provider>

              {code:xml}

              • 4. Re: Consuming messages from a remote HornetQ node
                kconner

                Strange, that should be the default mapper.

                 

                Kev

                • 5. Re: Consuming messages from a remote HornetQ node
                  kconner

                  Sorry, it should actually fail to deploy which means that we have a property missing in the jbossesb-proerties.xml for that ra.

                   

                  The following is missing

                   

                  <property name="org.jboss.soa.esb.jca.activation.mapper.hornetq-ra.rar" value="org.jboss.soa.esb.listeners.jca.JBossActivationMapper"/>
                  • 6. Re: Consuming messages from a remote HornetQ node
                    a.novarini

                    Sorry if I revive this thread, but I have "more or less" the same problem, and despite your instructions I can't make it working.

                     

                    Now the definition of "more or less"...

                     

                    JBossESB version 4.9

                    HornetQ version 2.1.2

                    JBossAS version 5.1.0.GA

                     

                    I started at first following this link http://community.jboss.org/wiki/HornetQ212onJBossAS510GA, so that I was sure about esb communicating with HornetQ installed locally; by locally I mean not only on the same machine, but also into the same JBossAS instance.

                     

                    The examples included into the esb package worked fine.

                     

                    Then I followed these instructions http://hornetq.sourceforge.net/docs/hornetq-2.1.2.Final/user-manual/en/html/appserver-integration.html#d0e7966, to point to a remote HornetQ instace; again, with remote I mean outside JBossAS, but yet on the same machine.

                     

                    The problems for me started from now on. Basically, JBossAS seems to ignore HornetQ, even if you configure the connectors to point to a wrong port, everything works in the same way, with the esb communicating with the internal HornetQ; no exception about connection refused, I guess this would happen just when someone really tries to connect to it, but it's another thread...

                     

                    Next, I tried to follow what Noel said, so I put the mapper property into the jboss-esb.xml fle; is it correct?

                    Now something interesting happened: the esb example seemed not to use the internal HornetQ, but it didn't use the remote one either; but again, no exceptions were thrown.

                     

                    So, taking as example the HelloWorld, before the "mapping thing" I could see the correct output, after no output at all. Moreover, if you put a wrong port into the connector configurations, JBoss hung waiting for a connection to be closed, something it couldn't obviously happen, but at least I had the confirmation that somehow that was used.

                     

                    The JMX monitoring of HornetQ said that no message came to the queues configured on it.

                     

                    I'm hoping there's still a little step to do to complete the configuration, but I'm stuck and clueless.

                     

                    Any idea?

                     

                    Thanks in advance

                    Ale

                    • 7. Re: Consuming messages from a remote HornetQ node
                      paulman

                      Noel, you mentioned that you had the normal jms-provider working.  Can you post a zip of an example that works?  I've been unable to get a consumer working with the JCA configuration.

                      • 8. Re: Consuming messages from a remote HornetQ node
                        noelo

                        Hi Paul,

                        The jboss-esb.xml attached in the 3rd post down has the jms-provider configuration that I used in it (but its commented out).

                         

                        hth

                        Noel

                        • 9. Re: Consuming messages from a remote HornetQ node
                          paulman

                          Hi Noel

                           

                          I've been looking at this again. Can you verfiy that this is correct according to your jboss-esb.xml for a jms provider as the example lists hornetQ as the jca-provider instead of the jms-provider:

                           

                          <jms-jca-provider name="HornetQ"

                                                                       connection-factory="ConnectionFactory"

                                 <!--providerAdapterJNDI="java:/HornetQJMSProvider"-->

                               >

                                                             <jms-bus busid="quickstartGwChannel">

                                                                       <jms-message-filter

                                                                                                dest-type="QUEUE"

                                                                                                dest-name="queue/quickstart_jms_transacted_Request_gw" transacted="false"/>

                                                             </jms-bus>

                           

                                 <jndi-URL="jnp://10.64.132.5:1099"

                                                                            jndi-context-factory="org.jnp.interfaces.NamingContextFactory"

                                                                            java.naming.factory.url.pkgs="org.jboss.naming:org.jnp.interfaces">

                           

                                 <activation-config>

                                                                            <property name="ConnectorClassName" value="org.hornetq.core.remoting.impl.netty.NettyConnectorFactory" />

                                                                            <property name="ConnectionParameters" value="host=10.64.132.5;port=5445" />    

                                                             </activation-config>

                                              </jms-jca-provider>

                           

                           

                           

                          Thanks

                          Paul

                          • 10. Re: Consuming messages from a remote HornetQ node
                            noelo

                            Hi Paul,

                            Its been a while since I've looked at this but here are the files that I used. The remote HornetQ JMS node is first bound to JNDI and this is looked up from the JCA-JMS provider.

                             

                            hth

                            Noel