1 2 Previous Next 16 Replies Latest reply on Mar 3, 2011 9:16 AM by sergiu_pienar

    ha failover setup with JNDI

    bjchip

      There is a reference to using jms to instruct JNDI of the connection factories but I am missing some details.  In 38.2.4.1 it describes "using the JMS service on the server to load your JMS connection factory into JNDI"  ... on the server. 

       

      I've successfully done this with the cluster.. but it is not clear how I should do HA.   There seems to be some basic information about the JNDI implementation I need.

       

      I am currently integrating this with JBoss Servers.  They have HAJNDI.  Do I actually need to point my JBoss Server at the standalone hornetq JNDI instance?  I have made several examples work and have connected to a clustered hornetq standalone this way.  What I don't know about JNDI is what is giving me fits, and looking it up on the web simply floods me with app specific information, though this appears to answer me a bit...

       

      http://www.theserverside.com/tt/articles/article.tss?l=J2EEClustering

       

      ...but is the JNDI we have in hornetq the same shared global clustering as in JBoss?

       

      The JNDI remains a singleton connection, I can connect JNDI to one IP or the other.  If the JNDI server disappears (as is likely if the hornetq JMS node it is on disappears) , then how does the JBOSS client work out where things are now?   I don't want my apps to have to re-code the java, just to look up the connection factory.  The examples all show localhost but I THINK that is so that the examples stay simple.

       

      I THOUGHT that if I were broadcasting the cluster information (as I would be), that there would be some way of instructing the JNDI connector on the client that there is another place to connect to JNDI.   Maybe this isn't really a hornetq question.  My problem is that the lookup of JNDI as implemented in hornetq doesn't look like the list of providers in HAJNDI and I am not really clear about how interconnected the JNDI is.

       

      I'll be experimenting with this but it seems that the JNDI service becomes a point failure.   Maybe there is a way of configuring JNDI to failover (haven't found that yet).  Does the JNDI of hornetq talk to the HAJNDI of JBoss?  Can I just aim at the JBoss localhost JNDI? 

       

      Some discussion around this would help a lot with the details. 

       

      Thanks all

       

      BJ

        • 1. Re: ha failover setup with JNDI
          clebert.suconic

          Forget JNDI for a second.

           

           

          JNDI just gives you.. err.. names.

           

           

          If you use HA-JNDI that means the JNDI tree will connect to another server case that server dies. That doesn't have much to do with HornetQ.

           

           

          In fact.. you don't even need JNDI to connect to HornetQ. You could just instantiate your objects directly and you would still be able to talk to the server.

           

           

          Look at the documentation about Failover and Clustering on HornetQ's documentation.

          • 2. Re: ha failover setup with JNDI
            bjchip

            Well, part of the objective  for me is to not rewrite the applications.   That keeps many people at higher pay grades than mine happy with me (and hornetq).    :-)

             

            They just want to look up connection factories that can get them to the queues and topics they need.  I am figuring out how.

             

            The HA section says I can do server discovery and points back at clustering in chapter 38 where discovery is discussed.   Discovery examples have the jndi services on localhost running on different ports... advertising clusters.  Which makes sense as they are all set up on the same machine in the examples.  I have set up two machines so it is the same port... but should I still be using localhost?  OR ... should I be aiming at the JNDI server on the specific IP?

             

            If I have a JBoss instance on host1,  and hornetqLive on host2, and hornetqBackup on host3 ....

             

            Should the JBoss instance look at its own host1 localhost jndi to get JMS, and the hornetq instances look at THEIR localhost jndi?

            (assuming I have put the hornetq libraries in place and done the resource adapter)...

             

            Should the JBoss instance on host1  be looking for the JNDI on host2  (which I now suspect is a mistake but I didn't until a few minutes ago, suspect that JNDI instances talk to each other at all).

             

            For those of us who haven't paid much attention (been paid to pay much attention) to what JNDI is actually doing under the hood, its relationship to the clustering and HA fallback arrangements aren't clear.   It looks like a potential single point failure, and as it is used, it almost certainly cannot be. 

             

            The answer must be that everyone else knows something I don't.      I figure that asking would be smarter than not knowing.   :-)

             

            respectfully

            BJ

            • 3. Re: ha failover setup with JNDI
              clebert.suconic

              "Well, part of the objective  for me is to not rewrite the applications.   That keeps many people at higher pay grades than mine happy with me (and hornetq)."

               

               

              JNDI just provide you just a directory for names. You can configure this whenever you want. You have the freedom you need for this.

               

               

              Just use the topology you need. You probably need each instance to look at its own instance's JNDI.


              • 4. Re: ha failover setup with JNDI
                bjchip

                Lets try this another way.  Node1 has address 192.168.1.100  Node2 has 101

                 

                Node1Node2Node 3Node 4
                JBoss1JBoss2Hornetq Standalone LiveHornetq Standalone BU
                Node address 192.168.1.101192.168.1.102192.168.1.103192.168.1.104
                JBoss Client JNDI URL  192.168.1.103:1099JBoss Client JNDI URL 192.168.1.104:1099JNDI bind 192.168.1.103:1099JNDI bind 192.168.1.104:1099

                 

                 

                If I bind to the node address so that the JNDI is available a localhost JNDI of JBoss isn't seeing the queues and topics.

                 

                If on the other hand, I point to the bound URL of my hornetq, I get the queues and topics.  However... I only have ONE url I can connect to AFAIK.  Hornetq does not serve up hajndi... JBoss can run it though.     Is this the JBoss method of getting both addresses?     The manner in which I cope with the JNDI for failover situations is not clear.

                • 5. Re: ha failover setup with JNDI
                  clebert.suconic

                  Let me put some other way...

                   

                   

                  If you have questions about JNDI, you have to ask on the Jboss forums.

                   

                  JBoss Application Server provides you HA-JNDI. But as I said before you only have the failover of the JNDI. Which is basically a hashtable.

                   

                   

                  For HornetQ, you really need each node (live and backup) being replicas.

                   

                  If you need JNDI to fail over on standalone the JNDI connection could be done through a list of IPs on the jndi.properties (refer to the JBoss manual for that). so if one node is down, the connection to the JNDI will fail over to the backup.

                   

                  Case you're not using replication, you just need your JNDI to list the servers you have.

                   

                   

                   

                  From this thread I have the impression you're confusing HA-JNDI with HornetQ's cluster.

                  1 of 1 people found this helpful
                  • 6. Re: ha failover setup with JNDI
                    bjchip

                    Well yes :-)

                     

                    I HAVE been confused, because a standalone live-backup setup isn't a whole heap of good unless the clients can find the backup.

                    Reading the docs there is a reference to hajndi but not enough information (just my opinion) on how it gets done.

                    It isn't clear (because this is a JBoss microcontainer) that hajndi (which comes with JBoss) isn't available.   

                     

                    A sample simple line or 2 from a config that does jndi lookup and fails over when it has to, would be a really nice thing to see.

                     

                    Where and how  to modify my jndi properties in jboss so the apps can SEE the standalone live-backup is what I want to get at..  the standalone is very attractive on several points (particularly if it is time to resync a backup server).... but the apps have to find it.

                     

                    Yes... I was looking for a way to cope with this through discovery or fallback.   It looks like hajndi is the only way to do that, and that is a surprise to me.

                     

                    I looked at the clustering arrangements and said to myself "great I can just list the nodes with this connector" but it doesn't work that way for JNDI.  I am still puzzled.  Wading through the hajndi info now.

                     

                    Not so much confused at this point, but still wanting to do something sensible connecting the standalone config to the webcontainers as live-backup without putting it IN the webcontainer.  I'd really rather not bring down my Application Server to resync an errant backup messaging server.  

                     

                    Thanks

                    BJ

                    • 7. Re: ha failover setup with JNDI
                      timfox

                      bjchip wrote:

                       

                      Well yes :-)

                       

                      I HAVE been confused, because a standalone live-backup setup isn't a whole heap of good unless the clients can find the backup.


                      You don't need HA-JNDI for that. HornetQ clients allow live backup pairs to be discovered using UDP discovery. See user manual HA chapter for more info.

                       

                      The rest of your questions seem to concern how to configure HA JNDI. Like it says in the manual, HA-JNDI is a service of JBoss app server and thoroughly documented in the JBoss AS documentation

                       

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


                      1 of 1 people found this helpful
                      • 8. Re: ha failover setup with JNDI
                        bjchip

                        If my client was standalone I wouldn't care enough to keep pestering you folks.

                         

                        My "client" is a middlesized monster collection of applications inside a jboss container.   

                         

                        ...and from what i've seen so far *I* really really want to have hornetq as my message manager.

                         

                        I want hornetq OUTSIDE of jboss to replace the messaging inside of jboss.  (This is partly because of the need to drop the servers and copy the data to get back to live-backup configuration after one has failed ).      

                         

                        So setting up discovery at the application level isn't actually what I want.    I may not GET what I want either :-)

                         

                        I want jboss to be able to find the server -and- the backup.

                         

                         

                        Thanks

                        BJ

                        • 9. Re: ha failover setup with JNDI
                          timfox

                          I'm not sure where the confusion is.

                           

                          You don't need JNDI at all for the client to find the live and the backup. This works fine for standalone HornetQ servers outside of JBoss.

                          • 10. Re: ha failover setup with JNDI
                            bjchip

                            There are 20+ clients all expecting to get the their connection factories through jndi.  Each has to be modified to be hornetq a hornetq client if I can't handle it at the jboss level.    I am impressed with the way this works.  It isn't  that easy to integrate into older projects  (in AS4 at least).  Not that anyone else could do better, just that I am somewhat stuck with what is possible.

                            • 11. Re: ha failover setup with JNDI
                              clebert.suconic

                              I guess this is the 10th time I already say that JNDI is just like a distributed HashMap. You give it a string, you get a object.

                               

                               

                              You will get out of JNDI whatever you configure.

                               

                              You register your connection factories there.. your clients will be able to get it.

                               

                               

                              If you want more specific questions about JNDI, ask on the JBoss forums. For HornetQ all you need is to get access to a factory through direct instantiation or through JNDI.

                              • 12. Re: ha failover setup with JNDI
                                bjchip

                                Can I tell the standalone server to use the jndi service on a jboss server? 

                                 

                                Please be patient... I have just had to pick up jboss and hornetq clustering together in the past week.   Examples worked, but the real world is not so friendly.

                                 

                                respectfully

                                BJ

                                • 13. Re: ha failover setup with JNDI
                                  ataylor
                                  I dont think i understand what you are trying to achieve, The standalone server doesnt use the jndi service for lookups  only for registering its own resources, its the client that uses the jndi service?
                                  • 14. Re: ha failover setup with JNDI
                                    bjchip

                                    The clients live in JBoss and their reconfiguration  to use external jndi is something to be avoided. 

                                     

                                    Can I tell the standalone server to register its objects with the JNDI on the JBoss?

                                     

                                    I think this is permitted and possible from what I read in the manual, and what has gone on here, but I don't know quite how to go about it.

                                     

                                    Respectfully

                                    BJ

                                     

                                    (currently luxuriating in the satisfaction of having inferred a broken UDP and proven it by making a TCP JBoss Cluster work)

                                    1 2 Previous Next