2 Replies Latest reply on Apr 10, 2008 4:05 AM by Tim Fox

    Message redistibution between 2 MDB's

    Samuel Fruchter Newbie

      Hello,

      I have 2 nodes in cluster which has same mdbs. How do I have for having that the 2 nodes consume the same number of message themself.

      Should I use message redistribution or clustered connection factories ?


      Example : I send 10 msgs to a queue A which is deployed on the 2 nodes. MDBs listen to it. I want that the node 1 treats 5 and the node 2 treats also 5 messages from the queue A.

      Sam

        • 1. Re: Message redistibution between 2 MDB's
          Clebert Suconic Master

          The ClusterRoundRobingDistributor aways favour the local queue on the Cluster.

          public Delivery handle(DeliveryObserver observer, MessageReference ref, Transaction tx)
           {
           //First try the local distributor
          
           if (trace) { log.trace(this + " first trying with local distributor"); }
          
           Delivery del = localDistributor.handle(observer, ref, tx);
          
           if (trace) { log.trace(this + " local distributor returned " + del); }
          
          

          So.. if you have your MDB on ServerA and Producer on ServerA, the MDB on ServerA will aways receive the messages.


          If you were sending to a ServerC with no consumers on it, then the load would be balanced between ServerA and B.

          If you need that kind of load, you could be using two producers, on two distinct connections created by a ClusteredConnectionFactory.

          • 2. Re: Message redistibution between 2 MDB's
            Tim Fox Master

            To elaborate on what Clebert has already said - also I think this has been covered before on other threads.

            JBoss Messaging has "connection load balancing" - this means that if you use a connection factory with the attribute "supportsLoadBalancing" set to true, then subsequent create connection attempts will be made on different nodes of the cluster in a round robin fashion, the first node is chosen randomly.

            This gives an even distribution of connections across the cluster.

            If you have a clustered queue deployed on all nodes of the cluster, and a MDB consuming on all nodes from that queue, and you send a message via one of the connections you created to one of the nodes, then, if the local MDB exists and is not busy , JBM will always *favour* the local MDB. There is no point in the message being processed on another node if it can be happily processed on the local node (it's a waste of network hops).

            Here's the bit Clebert did not mention: If the local MDB does not exist or is busy, and another MDB on another node for the same queue is idle then the remote MDB can pull messages from other nodes - this is called "message redistribution".