8 Replies Latest reply on Dec 29, 2008 9:59 AM by rana24

    Cluster messaging distribution

      I have gone through most of the past post on the same topic still there is one unanswered question.

      We have a clustered set up for JBM-1.4.0 SP3 with JAS-4.2.1 , two instance A n B are part of the cluster.
      We have a test client which inside a for loop does follwing.

      QueueConnectionFactory qcf = (QueueConnectionFactory) cntxt
       .lookup("/ClusteredConnectionFactory");
      
       Queue queue = (Queue) cntxt.lookup("queue/RequestQueue");
       QueueConnection qc = qcf.createQueueConnection();
       QueueSession qs = qc.createQueueSession(false,
       Session.AUTO_ACKNOWLEDGE);
       QueueSender queueSender = qs.createSender(queue);
      ObjectMessage msg = qs.createObjectMessage(batchId);
      queueSender.send(msg);
      


      Here we are using HA-JNDI for lookup.
      We are using default ClusterredConnectionFactory which has ,
      <attribute name="SupportsFailover">true</attribute>
      <attribute name="SupportsLoadBalancing">true</attribute>
      <attribute name="LoadBalancingFactory">org.jboss.jms.client.plugin.RoundRobinLoadBalancingFactory</attribute>
      

      For RequestQueue is set to Cluster TRUE in destination-service.xml.
      As per our expectation messages should be distributed in round robin fashion , We have around 80% results when it is not distributed in round robbin fashion.
      Is there any other attribute which controls distribution ?
      For some cases it goes to one server only.
      Our client runs on different server so A and B both are remote server for client.






        • 1. Re: Cluster messaging distribution
          timfox

          The first node is chosen randomly when creating the first connection from a clustered connection factory.

          See http://www.jboss.org/file-access/default/members/jbossmessaging/freezone/docs/userguide-1.4.2.GA/html/c_configuration.html#c_conf.clusteredcfs

          In your case, you only create one connection on the cf before throwing it away, so it will always be random.

          Round robin only applies to subsequent connections from the same connection factory.

          • 2. Re: Cluster messaging distribution

            Thanks Tim,
            Okey I got it now.
            So if we have multiple stand alone clients which independently throws message. is there anything by which we can get message distribution in round robbin fashion. ( I can see one way , by implementing WebClient and exposing it through Apache Load balancer).

            • 3. Re: Cluster messaging distribution
              timfox

               

              "rana24" wrote:

              So if we have multiple stand alone clients which independently throws message. is there anything by which we can get message distribution in round robbin fashion.


              Yes, like it says in the docs, only the first node is chosen randomly, the subsequent ones are chosen round robin from the same connection factory.

              • 4. Re: Cluster messaging distribution

                In our case , each stand alone client will be sending only one message...so ideally they will do following
                Lookup ConnectionFactory,
                Create Connection,
                LookUp Queue
                and send
                But what I would like to achieve is if first stand alone client has sent it to server A, the next Stand alone client should talk to Server B.
                Is that feasible with current framework ?

                • 5. Re: Cluster messaging distribution
                  timfox

                   

                  "rana24" wrote:
                  In our case , each stand alone client will be sending only one message...so ideally they will do following
                  Lookup ConnectionFactory,
                  Create Connection,
                  LookUp Queue
                  and send
                  But what I would like to achieve is if first stand alone client has sent it to server A, the next Stand alone client should talk to Server B.


                  I don't think this is feasible. For Client B to connect to Server B it would have to know that Client A had "previously" connected to Server A. That means inter client communication, which is a) slow b) complex c) probably isn't even possible due to firewalls etc.


                  • 6. Re: Cluster messaging distribution
                    timfox

                    BTW - looking up a connection factory, create a connection, to send every message is a classic *anti-pattern*.

                    Don't do it, it will be slow.

                    • 7. Re: Cluster messaging distribution

                      Thanks Tim for your suggestion,
                      Will sit and try to get rid of this anti-pattern.

                      • 8. Re: Cluster messaging distribution

                        Tim,
                        To get rid off anti pattern stuff,
                        We have a Servicelocator implementation , which keeps a static map of Queue ,ConnectionFactory and other objects.
                        So we are not creating or looking up new Queue everytime, but trying to use it from map.
                        I seriously doubt abt. this because the stored Queue might be from any one server of the cluster so, message would go to that server only right ?
                        Am i thinking in right direction ?
                        If yes , so we need to look up Queue everytime from existing Factory right ?

                        Your comment will help us.