1 2 Previous Next 16 Replies Latest reply on Mar 15, 2010 5:39 AM by sv_srinivaas

    Tomcat client,mdb failover issue

    radhikasivaraj

      Hi,

      Unable to get this scenario working. i've read all the documentation but still no clue.

      I have a queue at node A and a back up queue at node B.

      I've a tomcat client application using spring jmsTemplate to send messages to nodeA.

      MDB in node C picks the message from node A.

      When nodeA crashes, nodeB starts up and i can see the backup server activated and also all the queues are displayed in JMX console of node B as expected. Great till now.

       

      I have two issues after crashing node A.

      1. The tomcat client application is now unable to send messages to nodeB and it still tries to connect and send to nodeA.

      Exception that I get :

      Caused by: HornetQException[errorCode=2 message=Unable to connect to server using configuration org-hornetq-integration-transports-netty-NettyConnectorFactory?port=5445&host=ip of nodeA]

       

      2. My MDB is not listening to my queue in nodeB.

       

      What do I do to get tomcat send messages to node B instead of node A

      AND

      mdb to listen to node B instead of node A.

       

      PS: I've run the sample failover examples which work perfectly. It is this scenario that is not working may be because the client is Tomcat in my case and/or i'm using MDBs to receive messages. Please help.

       

      Thanks,

      Radhika

       

        • 1. Re: Tomcat client,mdb failover issue
          timfox

          Please take a look at:

           

          http://community.jboss.org/wiki/Howtoreportabugissue

           

          and

           

          http://community.jboss.org/wiki/CanIusetheSpringJMSTemplatewithHornetQ

           

          You'd need to remove the Spring JMS Template from the equation for us to see what's wrong.

          • 2. Re: Tomcat client,mdb failover issue
            ataylor

            This is not working because of th eway the spring jms template works.. firstly i would recommend reading the following http://community.jboss.org/wiki/CanIusetheSpringJMSTemplatewithHornetQ.

             

            So in the failover excample the following occurs.

             

            1. client connects to node1

            2. node 1 dies

            3. client fails over to node 2.

             

            pretty simple. with Spring jms template the following happens

             

            1. client connects to node 1 and sends a message

            2. client disconnects.

            3. node 1 dies.

            4. client tries to reconnect to node 1 ----> this will always fail since the server is not there any more.

            • 3. Re: Tomcat client,mdb failover issue
              ataylor
              regarding part 2 of your question, this is done by configuring the jca adapter and is explained fully in the user manual.
              • 4. Re: Tomcat client,mdb failover issue
                radhikasivaraj

                Thanks for your quick response.

                 

                Tim, I'll try removing spring template and check.

                 

                For mdb, I've gone through the user manual jca sections and thats how I configured my ra.xml. Everything works fine before crash and only on failover to nodeB the MDB fails to connnect to nodeB.

                 

                After seeing this post http://community.jboss.org/message/73364#73364 I tried giving DiscoveryAddress and DiscvoveryPort in the config property of ra.xml but I still could not get the MDB to connect to nodeB on failover.

                 

                I've attached ra.xml and jms-ds.xml. Pls let me know if there is anything wrong.

                • 5. Re: Tomcat client,mdb failover issue
                  ataylor

                  you can see from looking at the ra config that it is only connectiong to nodeA , i.e. <config-property-value>host=nodeA;port=5445</config-property-value>.

                   

                  take a look at the user manual section http://hornetq.sourceforge.net/docs/hornetq-2.0.0.GA/user-manual/en/html_single/index.html#d0e7138 on how to configure it correctly.

                  • 6. Re: Tomcat client,mdb failover issue
                    radhikasivaraj

                    Andy, Thank you so much for pointint it out. MDB failover works fine now.

                     

                    I just have one more question regarding spring jms listener. Should i not use spring jms listener too similar to spring jms templates because i have the same issue with spring listeners on failover.

                     

                    Using spring listeners because it supports dynamic selectors which we definitely need, thats why i'm curious to know if there is any work around to make spring listeners work on failover with Hornetq.

                    • 7. Re: Tomcat client,mdb failover issue
                      ataylor

                      the spring jms listener is also an anti pattern as discussed in the article so i would suggest not using it.

                       

                      As for spring dynamic selectors, i am not sure what they are. if you explain on more detail what you are trying to do i may be able to help.

                      • 8. Re: Tomcat client,mdb failover issue
                        timfox

                        The best thing is not to use any of the Spring wrappers around the JMS API.

                         

                        What's wrong with the JMS API?

                        • 9. Re: Tomcat client,mdb failover issue
                          radhikasivaraj

                          Hi, I dont have any issue with JMS api, it is for the asynchronous receive behavior I used spring listener (which also supports dynamic selector(to consume certain messages based on some condition) which MDB doesn't (only supprts static selector).

                          Also there is an issue when I configure queue nodeB as another live node instead of a backup of nodeA, i.e now there are two queue nodes in cluster nodeA and nodeB.

                           

                          MDB is deployed in nodeC and not part of cluster which gets connected to nodeA by auto-discovery and picks all messages from nodeA.

                           

                          When nodeA is killed (i'm not using ctrl-c on the command line), MDB is unable to discover nodeB.

                           

                          Will auto discovery not work in case if a node failure as i've configured ra.xml to use the Discovery address and port?

                           

                          Attached ra.xml.

                          • 10. Re: Tomcat client,mdb failover issue
                            sv_srinivaas

                            Hi, I too have the same issue with MDB in Jboss 5.0/ 5.1 GA and Hornetq GA.

                             

                            When I start a backup node and a live queue node and if the live node crashes then the MDB starts listening to back up node automatically which is good.

                             

                            But if I just start two live nodes (in cluster) and if one of them crashes (where the MDB is currently listening to) then the MDB does not auto discover the other active node. Pls help.

                            • 11. Re: Tomcat client,mdb failover issue
                              timfox

                              Like it describes in the user manual (HA chapter), connections fail-over from live nodes to *backup* nodes, not from live nodes to other live nodes.

                               

                              If you want to failover from live-->live nodes you can add a feature request in JIRA if you like.

                              • 12. Re: Tomcat client,mdb failover issue
                                radhikasivaraj

                                Tim,

                                 

                                The MDB failover from live -->live nodes seems to be working, only the reply messages from mdbs are not sent after failure.

                                 

                                Started two nodes node1 and node2 both as live nodes but (by mistake) I configured node2 as a backup node for node1 in ra.xml. Started MDB in node3 which was configured to consume messages from node1.

                                 

                                Everything worked fine and messages were distributed to node1 and node2 in round robin style. When node1 is killed, mdb automatically failed over from node1 to node2 and started consuming messages from node2 though it is not a bakcup server.

                                 

                                Is this the expected behavior?

                                • 13. Re: Tomcat client,mdb failover issue
                                  clebert.suconic

                                  I'm not sure what you meant by:

                                   

                                  "The MDB failover from live -->live nodes seems to be working, only the reply messages from mdbs are not sent after failure."

                                   

                                   

                                  Is it working fine or not?

                                  • 14. Re: Tomcat client,mdb failover issue
                                    sv_srinivaas

                                    Hi, I understand from the above posts that MDB cannot failover from one live node to another live node automatically, but is it possible through code to handle this so that the MDB can failover from one queue live node to another?

                                     

                                    Say in my case I have a cluster of two queue nodes A and B. I've my MDB in node c and by default it picks messages from node A only.

                                     

                                    When nodeA goes down, my MDB goes idle and yes i do understand that Hornetq2.0.0. GA does not support MDB auto failover from one live to another live node, but is there a way that i can handle it in my code so that after 5 attempts it should connect to nodeC and pick messages from there?

                                     

                                    Pls help. Thanks!

                                    1 2 Previous Next