8 Replies Latest reply on Oct 4, 2011 7:04 AM by lars-ho

    HornetQ as Resource Adapter - JNDI Lookup

    germ

      Perhaps someone can tell me what's wrong here.  It might be something obvious, but I'm starting to suspect not.  I'm trying to deploy HornetQ (2.2.5 Final) as a resource adapter to connect to an external HornetQ instance in JBoss AS (7.0.1).

       

      I extract hornetq-ra.rar and modify ra.xml to configure a few things, as this seems to be required by this bug:

       

      https://issues.jboss.org/browse/AS7-1452

       

      I then edit my standalone.xml file, and modify the resource adapters subsection, like so:

      <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0">
        <resource-adapters>
          <resource-adapter>
            <archive>hornetq-ra.rar</archive>
            <transaction-support>XATransaction</transaction-support>
            <config-property name="UserName">myusername</config-property>
            <config-property name="Password">mypassword</config-property>
            <connection-definitions>
              <connection-definition class-name="org.hornetq.ra.HornetQRAConnectionFactory" jndi-name="java:/jms/RemoteConnectionFactory" enabled="true" use-java-context="true" pool-name="JmsRemoteConnectionFactory" use-ccm="true">
                <config-property name="UserName">myusername</config-property>
                <config-property name="ConnectionParameters">host=localhost;port=5445</config-property>
                <config-property name="ConnectorClassName">org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</config-property>
                <config-property name="SessionDefaultType">javax.jms.Queue</config-property>
                <config-property name="Password">mypassword</config-property>
                <pool>
                  <min-pool-size>10</min-pool-size>
                  <max-pool-size>100</max-pool-size>
                </pool>
                <security>
                  <application>true</application>
                </security>
              </connection-definition>
            </connection-definitions>
          </resource-adapter>
        </resource-adapters>
      </subsystem>
      

      The HornetQ resource adapter does seem to deploy successfully, so I don't think my problem is there.  However, when I attempt to make use of this connection factory in a test EJB:

      @Startup
      @Singleton
      @TransactionAttribute(TransactionAttributeType.REQUIRED)
      public class Sender {
           @Resource(lookup="java:/jms/RemoteConnectionFactory")
           private QueueConnectionFactory connectionFactory;
      

      ...  I have much less success, resulting in my test project not deploying with the following error:

      INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 1) Deployment of "test.jar" was rolled back with failure message {"Services with missing/unavailable dependencies" => ["jboss.naming.context.java.comp.test.test.Sender.\"env/test.Sender/connectionFactory\" missing [ jboss.naming.context.java.jms/RemoteConnectionFactory ]"]}
      

      Can anyone see anything wrong with my sample here, or is there something I don't understand about JNDI lookup and EJB3.1?

        • 1. Re: HornetQ as Resource Adapter - JNDI Lookup
          jaikiran

          HornetQ resource adapter is by default integrated in AS 7.0.1 (standalone-preview.xml of "everything" distribution). Which server profile and distribution are you using?

          • 2. Re: HornetQ as Resource Adapter - JNDI Lookup
            germ

            I see that HornetQ is built-in by default...  I didn't use that version because I couldn't figure out how to deploy that version and use it to as a client to connect to an external HornetQ.  It seems to be set up to run internally, and only that way.  I'm also not excited about the idea of tinkering with what is essentially the "inner workings" of JBoss AS like that.  (Honestly, I've found the documentation - or lack thereof - with AS 7 to be frustrating...  Though I do like what I've been able to figure out.)

             

            I'm using AS 7.0.1 (downloaded the "Everything" package)...  As for the profile, the only thing I've changed in the default standalone.xml is the above resource adapters section.  Does that answer what you're looking for?

            • 3. Re: HornetQ as Resource Adapter - JNDI Lookup
              germ

              The more I look at it, the more I don't believe the built-in HornetQ can be configured to connect to an external HornetQ.  I just don't see that being exposed in a way that I can configure in the messaging subsystem.

               

              This brings me back to attempting to do it as an external resource adapter.

               

              Anyone tried this?

              • 4. Re: HornetQ as Resource Adapter - JNDI Lookup
                germ

                At the risk of spamming my own thread, I have come across something else that might narrow down the problem.  It appears that this line in my standalone.xml:

                <connection-definition class-name="org.hornetq.ra.HornetQRAConnectionFactory" jndi-name="java:jboss/jms/RemoteConnectionFactory" enabled="true" use-java-context="true" pool-name="JmsRemoteConnectionFactory" use-ccm="true">
                

                Does not appear to actually register that object with the JNDI directory (like I would expect).  When I attempt to look the object up manually, it's not there.  So perhaps there is something wrong with this line, or something wrong with the resource adapter code that registers objects?

                • 5. Re: HornetQ as Resource Adapter - JNDI Lookup
                  lars-ho

                  I am struggling with the exact same thing. Anyone knows how to do this?

                  • 6. Re: HornetQ as Resource Adapter - JNDI Lookup
                    jaikiran

                    I actually don't have an idea on how the messaging subsystem has been integrated and what the expectations are on HornetQ usage. Someone from the messaging team might be able to answer.

                    • 7. Re: HornetQ as Resource Adapter - JNDI Lookup
                      jaikiran

                      Actually, after reading a post on the HornetQ forum for a similar question, I think there isn't much information on how this is expected to behave. So, please send a mail to the AS7 dev list https://lists.jboss.org/mailman/listinfo/jboss-as7-dev with the exact details on what you are looking for.  

                      • 8. Re: HornetQ as Resource Adapter - JNDI Lookup
                        lars-ho

                        Thanks, I will do that..