12 Replies Latest reply on May 9, 2006 9:24 AM by Maarten Roosendaal

    HA-JNDI in Cluster on 1 PC

    Maarten Roosendaal Newbie

      Hi,

      I was wondering if HA-JNDI works in a Cluster when it's configured for 1 machine (http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfiguringMultipleJBossInstancesOnOneMachine).

      HA-JNDI ports have to be different for each configuration and when you have a JMSClient on node 2 when the JMS Service is run on the masternode (node1) then the JMSClient cannot find the JNDI name java:/ConnectionFactory.

      The Client is in this case a Spring bean. Any idea (besides replacing Spring).

      Thanks,
      Maarten

        • 1. Re: HA-JNDI in Cluster on 1 PC
          Jerry Gauthier Apprentice

          HA-JNDI definitely works in a single machine cluster. I use it in this mode frequently and all of the HA-JNDI tests in the test suite do so as well.

          You can differentiate the HA-JNDI servers either through service-bindings or by using multihome addresses. In either case, HA-JNDI should work properly.

          • 2. Re: HA-JNDI in Cluster on 1 PC
            Brian Stansberry Master

            You have to look up ConnectionFactory, not java:/ConnectionFactory. java:/ConnectionFactory is for the JVM invocation layer, which only works in the same JVM as the JMS server.

            • 3. Re: HA-JNDI in Cluster on 1 PC
              Maarten Roosendaal Newbie

              Unfortunalty it does not work without the 'java:/' prefix. I get
              javax.naming.NameNotFoundException: ConnectionFactory not bound.

              On a multihomed PC you have to change the HA-JNDI port by changing the jboss-service.xml in the conf directory and the cluster-service.xml in the deploy directory. So how can i look up the JMS ConnectionFactory on Node2 when Node1 is the masternode and contains the JMS service.

              From the admin guide:
              The HA-JMS client must obtain JMS connection factories from the HA-JNDI (the default port is 1100).

              What am i missing?

              • 4. Re: HA-JNDI in Cluster on 1 PC
                Brian Stansberry Master

                How are you configuring your InitialContext? What are you setting as your javax.naming.provider.url?

                Should be something like

                javax.naming.provider.url=node1:1100,node2:1200

                assuming HA-JNDI is bound to 1100 on 1 and 1200 on 2.

                • 5. Re: HA-JNDI in Cluster on 1 PC
                  Maarten Roosendaal Newbie

                  Hi,

                  I'm using SpringJMS for the plumming:











                  1





                  ConnectionFactory



                  I just read that you can add environment properties to the template so i'll add the 2 nodes. But this is just a testenvironment, in real life we have 2 different machines, each hosting a node and running HA-JNDI on port 1100. My problem with adding env-props is that before i deploy my application in a real environment, i have to change these settings. My app is not a remote client but an app running in the cluster.

                  • 6. Re: HA-JNDI in Cluster on 1 PC
                    Maarten Roosendaal Newbie

                    Dead end again. The env-props work for a different bean with the same name. I'm posting on the Spring forum as well.

                    Nevertheless, i hope that the cluster documentation in the admin guide will be more extensive, especially for different environments and JMS.

                    Thanks,
                    Maarten

                    • 7. Re: HA-JNDI in Cluster on 1 PC
                      Maarten Roosendaal Newbie

                      It almost works but the following line:
                      javax.naming.provider.url=node1:1100,node2:1200
                      is a bit unclear on a multihomed machine. What do i need to fill in for node1 and node2? The name i gave the nodes? That doesn't work. Any suggestions?

                      • 8. Re: HA-JNDI in Cluster on 1 PC
                        Jerry Gauthier Apprentice

                        Use your server addresses. For example -

                        java.naming.provider.url=localhost:1100,localhost:1200

                        -or-

                        java.naming.provider.url=192.168.1.100:1100,192.168.1.101:1100

                        • 9. Re: HA-JNDI in Cluster on 1 PC
                          Maarten Roosendaal Newbie

                          Yep, that did it, i had to add some more Springplumming but it works fine now.
                          Thanks for the input.

                          • 10. Re: HA-JNDI in Cluster on 1 PC
                            Maarten Roosendaal Newbie

                            One question. Can i also edit the jndi.properties for each JBoss server in a cluster instead of configuring my client application. It runs within the cluster so it shouldn't be aware of any HA-JNDI configuration.

                            • 11. Re: HA-JNDI in Cluster on 1 PC
                              Brian Stansberry Master

                              If you change the jndi.properties within the server, you'll screw up the internal function of the server. You're much better off building up a Properties object and passing that to your InitialContext.

                              • 12. Re: HA-JNDI in Cluster on 1 PC
                                Maarten Roosendaal Newbie

                                I did that and it worked until i tested the failover. It seems that my Spring Bean does not know how to reconnect on the failover node:
                                2006-05-09 14:51:18,512 WARN [org.jboss.mq.Connection] Connection failure, use javax.jms.Connection.setExceptionListener() to handle this error and reconnect
                                org.jboss.mq.SpyJMSException: Exiting on IOE; - nested throwable: (java.net.SocketException: Connection reset)
                                at org.jboss.mq.SpyJMSException.getAsJMSException(SpyJMSException.java:66)
                                at org.jboss.mq.Connection.asynchFailure(Connection.java:437)
                                at org.jboss.mq.il.uil2.UILClientILService.asynchFailure(UILClientILService.java:156)
                                at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleStop(SocketManager.java:413)
                                at org.jboss.mq.il.uil2.SocketManager$ReadTask.run(SocketManager.java:345)
                                at java.lang.Thread.run(Thread.java:534)
                                Caused by: java.net.SocketException: Connection reset
                                at java.net.SocketInputStream.read(SocketInputStream.java:168)
                                at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
                                at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
                                at org.jboss.util.stream.NotifyingBufferedInputStream.read(NotifyingBufferedInputStream.java:67)
                                at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2133)
                                at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2313)
                                at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2380)
                                at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2452)
                                at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputStream.java:2601)
                                at java.io.ObjectInputStream.readByte(ObjectInputStream.java:845)
                                at org.jboss.mq.il.uil2.SocketManager$ReadTask.run(SocketManager.java:290)
                                ... 1 more

                                I made my own implementation using HASingletonSupport so the JMSSender only works on the masternode but this is a workaround for now.

                                Thanks for the input