1 2 Previous Next 20 Replies Latest reply on Feb 20, 2010 5:52 PM by Bill Schwanitz

    EJB in JBoss Connecting to a Standalone HornetQ Server

    Bill Schwanitz Newbie

      Hello,

       

      I'd like to configure JBoss/HornetQ to allow an EJB to publish a message to a topic on a standalone HornetQ server using a discovery group (without a HornetQ server running in JBoss).

       

      Is there any example of configuing the resource adapter for this scenario?

       

      Details:

       

      Everything seems to be working fine until my EJB attempts to call TopicConnectionFactory.createTopicConnection() - that method never returns.

       

      I have turned on debug logging and I see the following repeated many dozens of times in the server.log [starting from the moment the EJB called createTopicConnection()]:

       

      2010-02-11 16:40:34,842 FINE  [org.hornetq.integration.transports.netty.NettyConnector] (http-127.0.0.1-8080-1) Started Netty Connector version 3.1.5.GA-r1772

      I suspect I have something mis-configured in my ra.xml file. I have read the pertinent sections of the user manual but can't figure out what I'm doing incorrectly.

       

      I have attached a zip of the hornetq.sar and hornetq-ra.rar from the JBoss deployment.

       

      Thank you for your help,

      Bill

        • 1. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
          Clebert Suconic Master

          Take a look on the jca-config example.

           

          You need to pretty much configure a jca instance to talk to a remote server.

           

          on the jca-config example, you have an MDB talking to a remote server. On this example the remote server is inside another JBoss application server, but that doesn't make any difference.

           

           

          Also, look at the documentation. In particular to these sections:

           

           

          http://hornetq.sourceforge.net/docs/hornetq-2.0.0.GA/user-manual/en/html/configuring-transports.html

           

          http://hornetq.sourceforge.net/docs/hornetq-2.0.0.GA/user-manual/en/html/appserver-integration.html#d0e7138

           

          ( ^^ I would recommend the whole chapter 32 also)

          • 2. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
            Bill Schwanitz Newbie

            Clebert,

             

            Yes, I am able to run the jca-config example. So since that worked, I copied the jca-config-example-profile2 to a new deployment (named it default-with-hornetq-client). Then I added my EJB ear to that deployment's deploy dir.

             

            But still when my EJB attempts to call TopicConnectionFactory.createTopicConnection() - that method never returns.

             

            I'm still seeing the following repeated in the server.log (one entry every 3 seconds):

            2010-02-11 16:40:34,842 FINE  [org.hornetq.integration.transports.netty.NettyConnector] (http-127.0.0.1-8080-1) Started Netty Connector version 3.1.5.GA-r1772

             

            I have read through all the docs you referenced. I just can't see what I have improperly configured.

             

            I have attached a zip that contains my hornetq.sar and hornetq-ra.rar.

             

            Thanks for any help you can offer,

            Bill

            • 3. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
              Clebert Suconic Master

              The topicConnectionFactory is defined by the outbound connection on the jms-ds.xml.

               

              You didn't post your jms-ds.xml. Look at the jca example and you will see one:

               

               

              You should see something like

               

              <connection-factories>
              
              
                 <!--
                  JMS XA Resource adapter, use this for outbound JMS connections.
                  Inbound connections are defined at the @MDB activaction or at the resource-adapter properties.
                 -->
                 <tx-connection-factory>
                    <jndi-name>RemoteJmsXA</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.Topic</config-property>
                    <config-property name="ConnectorClassName" type="java.lang.String">org.hornetq.integration.transports.netty.NettyConnectorFactory</config-property>
                    <config-property name="ConnectionParameters" type="java.lang.String">port=5445</config-property>
                    <max-pool-size>20</max-pool-size>
                 </tx-connection-factory>
              
              
              </connection-factories>
               
              
              • 4. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
                Clebert Suconic Master

                on the connection properties, you can define any of the remoting configs specified on the manual.

                • 5. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
                  Clebert Suconic Master

                  Just found your jms-ds.xml at your file.

                  As I suspected.. you didn't define any remote connection options at the jms-ds.xml

                  • 6. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
                    Bill Schwanitz Newbie

                    Clebert,

                     

                    Thanks for your persistence trying to help me resolve this. Unfortunately, I still can't get it to work.

                     

                    I have attached the two -ds.xml files (jms-ds.xml and jms-remote-ds.xml). Notice, there is no tx-connection-factory in jms-ds.xml. The tx-connection-factory being used by my EJB is defined in jms-remote-ds.xml (jndi-name = JmsXA). Eventually, I'd like to use a discovery group for this connection, but in the hope of getting something to work, I defined a specific host IP of 192.168.1.104. I have a standalone HornetQ server running at this IP address. The JBoss with my EJB is running on 192.168.1.100.

                     

                    But still when my EJB attempts to call TopicConnectionFactory.createTopicConnection() - that method never returns.

                     

                    I'm still seeing the following repeated in the server.log (one entry every 3 seconds):

                    2010-02-16 10:48:34,562 FINE  [org.hornetq.integration.transports.netty.NettyConnector] (http-127.0.0.1-8080-1) Started Netty Connector version 3.1.5.GA-r1772

                     

                    I feel that I'm missing something very simple here - I just can't see it.

                     

                    So please tell me:

                    1. exactly what I need to change to get this to work pointed to a HornetQ server at a specific IP address

                    2. what the configuration should look like for the EJB in JBoss to use a discovery group (instead of the hardcoded IP address) to find the HornetQ server.

                     

                    I thank you for your continued help,

                    Bill

                    • 7. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
                      Clebert Suconic Master

                      You are specifying the ConnectorParameters twice on your XML. That's not how you do it. (I'm actually surprised JBoss AS didn't complain about it).

                       

                       

                      Try this instead:

                       

                      config-property name="ConnectionParameters" type="java.lang.String">host=192.168.1.104;port=5445</config-property>
                      • 8. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
                        Clebert Suconic Master

                        Also, there are two properties you could use on the Adapter, which are DiscoveryAddress and DiscoveryPort.

                         

                             <config-property name="DiscoveryAddress" type="java.lang.String">YourAddress</config-property>
                        
                           <config-property name="DiscoveryPort" type="java.lang.Integer">YourUDPPort</config-property>
                        
                        

                         

                        And I guess you wouldn't need to specify the ConnectorParams on this case.
                        Try the simple example first.. and then the UDP. Let me know if it doesn't work and I will take a look.
                        • 9. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
                          Bill Schwanitz Newbie

                          Celbert,

                           

                          Thank you again for your help on this!

                           

                          We are half way there. This syntax worked perfectly:

                          <config-property name=ConnectionParameters type=java.lang.String>host=192.168.1.104;port=5445</config-property>

                           

                          The EJB connected to the HornetQ server at 192.168.1.104:5445 and published the message into the queue. YAY!

                           

                          Unfortunately, the discovery group approach did not work. I used this syntax:

                             <tx-connection-factory>
                                <jndi-name>JmsXA</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.Topic</config-property>
                                <config-property name="ConnectorClassName" type="java.lang.String">org.hornetq.integration.transports.netty.NettyConnectorFactory</config-property>
                                <config-property name="DiscoveryAddress" type="java.lang.String">231.7.7.7</config-property>
                                <config-property name="DiscoveryPort" type="java.lang.Integer">9876</config-property>
                                <max-pool-size>20</max-pool-size>
                             </tx-connection-factory>

                          I believe this is the syntax you suggested.

                           

                          Thank you for offering to take a look. I'll be interested to hear what you discover.

                           

                          Cheers,

                          Bill

                          • 10. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
                            Tim Fox Master

                            Bill, all of this is explained in the user manual:

                             

                            http://hornetq.sourceforge.net/docs/hornetq-2.0.0.GA/user-manual/en/html/appserver-integration.html#d0e7138

                             

                            The full list of property names is listed, you'll notice, in particular there are:

                             

                            DiscoveryGroupAddress

                            DiscoveryGroupPort

                             

                            I suggest you thoroughly read that chapter, and the chapter on "configuring the transport" before proceeding, so you can understand the difference between connectors, acceptors, jca adaptors, inbound and outbound and how these related to MDBs.

                            • 11. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
                              Andy Taylor Master
                              also check the discovery examples work, this will verify that UDP is working properly on your network.
                              • 12. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
                                Clebert Suconic Master

                                sorry Bill, I confused the name of the parameters when I posted for you. Can you try as Tim suggested.

                                • 13. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
                                  Bill Schwanitz Newbie

                                  Tim, Clebert & Andy,

                                   

                                  Thank you all for your help on this.

                                   

                                  Tim, I have read and reread the sections in the manual to which you refer.

                                   

                                  Andy: Yes, I am able to run the discovery examples. I am also able to sucessfully form a cluster of standalone HornetQ servers using discovery on these two machines. I believe this is enough to conclude that UDP is working between the two machines.

                                   

                                  Clebert: No worries about the misnamed parameters.

                                   

                                  Unfortunately, changing the tx-connection-factory to use DiscoveryGroupAddress and DiscoveryGroupPort does not seem to work. I have attached the ds.xml that defines the tx-connection-factory. I have also attached the JBoss server.log (with org.hornetq and org.jboss.netty both set to DEBUG). I'm surprised that there isn't more helpful information from netty to help pinpoint the problem.

                                   

                                  BTW: the broadcast-group's broadcast-period is set to 1000 - so I would think that defining the DiscoveryInitialWaitTimeout on the tx-connection-factory should be sufficient even if a few UDP packets are lost.

                                   

                                  Thank you guys for all the help on this. We really want to use HornetQ on this project and this is the last bit of it that I need to get working.

                                   

                                  Cheers,

                                  Bill

                                  • 14. Re: EJB in JBoss Connecting to a Standalone HornetQ Server
                                    Bill Schwanitz Newbie

                                    Here is another data point that might be helpful. First let me give the code snippet I'm using to publish a message to a queue from my EJB: (note: I've omitted all the exception handling, etc)

                                     

                                    Context initialContext =new InitialContext();

                                    TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) initialContext.lookup("java:/JmsXA");

                                    TopicConnection topicConnection = topicConnectionFactory.createTopicConnection();

                                    TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

                                    Topic topic = topicSession.createTopic(topicName);

                                    TopicPublisher topicPublisher = topicSession.createPublisher(topic);

                                    topicPublisher.publish(mapMsg);

                                     

                                    As noted in previous entries in this thread, the EJB was calling topicConnectionFactory.createTopicConnection() and the method was never returning. I have found a way to get one step farther. By modifying the ra.xml as follows:

                                     

                                    Replace this:

                                          <config-property>
                                             <description>The transport configuration. These values must be in the form of key=val;key=val;</description>
                                             <config-property-name>ConnectionParameters</config-property-name>
                                             <config-property-type>java.lang.String</config-property-type>
                                             <config-property-value>port=5445</config-property-value>
                                          </config-property>
                                    with this:

                                          <config-property>
                                            <description>The discovery group address to use to autodetect a server</description>
                                            <config-property-name>DiscoveryAddress</config-property-name>
                                            <config-property-type>java.lang.String</config-property-type>
                                            <config-property-value>231.7.7.7</config-property-value>
                                          </config-property>
                                          <config-property>
                                            <description>The discovery group port to use to autodetect a server</description>
                                            <config-property-name>DiscoveryPort</config-property-name>
                                            <config-property-type>java.lang.Integer</config-property-type>
                                            <config-property-value>9876</config-property-value>
                                          </config-property>

                                    With this new configuration, the createTopicConnection() returns nicely. Unfortunately, now when my EJB calls createTopicSession(), that method never returns. The server.log does not look any different than my last post.

                                     

                                    Cheers,

                                    Bill

                                    1 2 Previous Next