14 Replies Latest reply on Jan 15, 2008 8:44 AM by bodrin b.

    unable to choose a default cluster node for messaging

    bodrin b. Newbie

      I want to setup something like a master-slave cluster - all jms clients (external) using only the master node and switch to the slave only if the master is down.

      So, first looking at http://docs.jboss.org/jbossas/jboss4guide/r4/html/cluster.chapt.html

      16.2.2. Client configuration
      
      The JNDI client needs to be aware of the HA-JNDI cluster.
      
      ...
      
      java.naming.provier.url=server1:1100,server2:1100,server3:1100,server4:1100
      
      
      When initialising, the JNP client code will try to get in touch with each server node from the list, one after the other, stopping as soon as one server has been reached. It will then download the HA-JNDI stub from this node.
      Note
      
      There is no load balancing behavior in the JNP client lookup process. It just goes through the provider list and use the first available server. The HA-JNDI provider list only needs to contain a subset of HA-JNDI nodes in the cluster.
      


      I can set it like this:
      java.naming.provider.url=master:1200,slave:1300
      


      Then I lookup the "/ClusteredConnectionFactory" which is configured to not support load-balancing via
      <attribute name="SupportsLoadBalancing">false</attribute>
      

      in JBOSS_CONFIG\deploy\jboss-messaging.sar\connection-factories-service.xml

      I have observed that subsequent createConnection() calls on the ConnectionFactory object chooses one and the same cluster node.

      The problem is that ones it is the master :

      ant
      Buildfile: build.xml
      
      identify:
       [echo] ###########################################################################
       [echo] # Running the DISTRIBUTED QUEUE example #
       [echo] ###########################################################################
       [echo] The queue: testDistributedQueue
       [echo] The client jar: ../..//jboss-messaging-client.jar
      
      sanity-check:
      
      init:
      
      compile:
      
      run:
       [java] Distributed queue /queue/testDistributedQueue exists
       [java] java.lang.RuntimeException: Assertion failed, 0 == 0
       [java] at org.jboss.example.jms.common.ExampleSupport.assertNotEquals(ExampleSupport.java:85)
       [java] at org.jboss.example.jms.distributedqueue.DistributedQueueExample.example(DistributedQueueExample.java:89)
       [java] at org.jboss.example.jms.common.ExampleSupport.run(ExampleSupport.java:147)
       [java] at org.jboss.example.jms.distributedqueue.DistributedQueueExample.main(DistributedQueueExample.java:173)
       [java]
       [java] #####################
       [java] ### FAILURE! ###
       [java] #####################
      
      BUILD FAILED
      


      ... but sometimes it is the slave :

      ant
      Buildfile: build.xml
      
      identify:
       [echo] ###########################################################################
       [echo] # Running the DISTRIBUTED QUEUE example #
       [echo] ###########################################################################
       [echo] The queue: testDistributedQueue
       [echo] The client jar: ../..//jboss-messaging-client.jar
      
      sanity-check:
      
      init:
      
      compile:
      
      run:
       [java] Distributed queue /queue/testDistributedQueue exists
       [java] java.lang.RuntimeException: Assertion failed, 1 == 1
       [java] at org.jboss.example.jms.common.ExampleSupport.assertNotEquals(ExampleSupport.java:85)
       [java] at org.jboss.example.jms.distributedqueue.DistributedQueueExample.example(DistributedQueueExample.java:89)
       [java] at org.jboss.example.jms.common.ExampleSupport.run(ExampleSupport.java:147)
       [java] at org.jboss.example.jms.distributedqueue.DistributedQueueExample.main(DistributedQueueExample.java:173)
       [java]
       [java] #####################
       [java] ### FAILURE! ###
       [java] #####################
      
      BUILD FAILED
      


      Do you know if it is possible to make such a setup that it will always choose the master (serviceID=0) node?
      I mean the one where the ha-jndi stub is connected to (There is no load balancing behavior in the JNP client lookup process.) ?

      Note that I have changed the distributed-queue example - I have added an InitialContext configuration:
      ...
       // connecting to the first node
       java.util.Hashtable properties = new java.util.Hashtable();
       properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
       "org.jnp.interfaces.NamingContextFactory");
       properties.put(javax.naming.Context.URL_PKG_PREFIXES,
       "org.jboss.naming:org.jnp.interfaces");
       properties.put(javax.naming.Context.PROVIDER_URL, "localhost:1200,localhost:1300");
      
       ic = new InitialContext(properties);
      ...