5 Replies Latest reply on Oct 23, 2010 2:01 AM by jaikiran pai

    JNDI Provider URL When Connecting to HQ Cluster

    Aspi Engineer Newbie

      When a JMS client is connecting to the JMS server which is part of the JBoss App Server (i.e. HornetQ), we specify the JNDI provider URL as "jnp://host:port". What should the value of the provider URL

      be if we are running a Hornet Q cluster in active/backup mode? We have tried using:

      jnp://host1:port1,host2:port2

      but that does not work as expected. Existing JMS client which were connected to JMS before the HQ server failover are able to reconnect. However new JMS clients that attempt to make a new JMS connection after the failover fail with the exception:

       

      java.lang.IllegalArgumentException: n must be positive

          at java.util.Random.nextInt(Random.java:250)

          at org.hornetq.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy.select(RoundRobinConnectionLoadBalancingPolicy.java:44)

          at org.hornetq.core.client.impl.ClientSessionFactoryImpl.createSessionInternal(ClientSessionFactoryImpl.java:1119)

          at org.hornetq.core.client.impl.ClientSessionFactoryImpl.createSession(ClientSessionFactoryImpl.java:849)

          at org.hornetq.jms.client.HornetQConnection.authorize(HornetQConnection.java:565)

          at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:624)

          at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:116)

          at com.putnam.jboss.topic.TopicReceive.init(TopicReceive.java:60)

          at com.putnam.jboss.topic.TopicReceive.run(TopicReceive.java:73)

          at com.putnam.jboss.topic.TopicReceive.main(TopicReceive.java:101)

       

       

      I have asked this question to the HQ team and they have directed me to the App Server team.

       

      Thanks

      Aspi Engineer

      Putnam Investments

        • 1. Re: JNDI Provider URL When Connecting to HQ Cluster
          Clebert Suconic Master

          I thought you were having a JNDI error after failover. The exception you posted is clearly a hornetq exception.

           

          How did you do it? did you lookup the factory after failover, or you kept the same factory before failover and created a connection right after?

           

           

          Can you show me some code on how you're doing it?

          • 2. Re: JNDI Provider URL When Connecting to HQ Cluster
            Wolf-Dieter Fink Master

            Normally this will be not JMS specific.

            with host:port[,host:port] you configure a number of cluster members that are ask for the JNDI lookup.

            You might also use the autodiscovery feature (AFAIK by default 230.0.0.4:1002) but you must be able to send/receive multicast.

             

            What port do you try as :port? Is it 1099 or 1100, 1100 will be the HA-JNDI port, that might be a difference.

            • 3. Re: JNDI Provider URL When Connecting to HQ Cluster
              Aspi Engineer Newbie

              Once the failover has completed, I try to create a new JMS connection using the exact same code/client that was used before the failover.  The exact same code works when the active instance (richmond2:6146) is still alive. The same code fails after the failover has occurred and the backup instance is now active.
              6146 is the value that I pass in via the JVM setting "-Djnp.port=6146"

               

              Thanks
              Aspi

               

              Code fragments:
                  static {
                      HQEnv.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                      HQEnv.put(Context.PROVIDER_URL, "jnp://richmond2.putnaminv.com:6146,richmond1.putnaminv.com:6146");
                      HQEnv.put(Context.SECURITY_PRINCIPAL, "jndiuser");
                      HQEnv.put(Context.SECURITY_CREDENTIALS, "putnam");
                      HQEnv.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                  }

               


                  InitialContext ctx = new InitialContext(HQEnv)
                  connFactory = (ConnectionFactory) ctx.lookup("cn=PUT_DEV.Extended.QueueConnectionFactory");
                   conn = connFactory.createConnection("jmsuser", "putnam");
                   log.info("Created connection...");

               

               

               

              • 4. Re: JNDI Provider URL When Connecting to HQ Cluster
                Clebert Suconic Master

                Aspi, this is probably a HornetQ issue.

                 

                 

                Can you please open an issue on HornetQ and we will investigate? This may be moot with the new Failover, but we will investigate it anyway.

                 

                Also:

                I'm asking privileges to helpdesk to give me privileges on this formum also but it may take a day or two..

                 

                 

                if someone who already have privileges could move this to the HornetQ user's forum please...

                • 5. Re: JNDI Provider URL When Connecting to HQ Cluster
                  jaikiran pai Master

                  Clebert Suconic wrote:

                   


                   

                   

                  if someone who already have privileges could move this to the HornetQ user's forum please...

                  Done

                   

                  Clebert Suconic wrote:

                   


                   

                  Also:

                  I'm asking privileges to helpdesk to give me privileges on this formum also but it may take a day or two..

                  Libor on #jbossorg (internal IRC) setup the privileges for me.