10 Replies Latest reply on Feb 18, 2005 7:53 PM by adrian.brock

    Multiply queue consumers

    magnusw

      Hi.

      I'm having multiply queue consumers connecting to JBossMQ. When I publish messages on the queue I want the messages to be round robin between the consumers but it seams like JBoss sends all the messages to the last connected consumer.

      Do anyone know if you can change this default behavior?

      I'm using JBoss 3.2.0.

      Thanks

      Magnus

        • 1. Re: Multiply queue consumers
          blackers

          I am by no means an expert on JMS, but this sounds to me as though you need to use Topics, not Queues. Queues are Point-To-Point and Topics are Point-To-MultiPoint

          Mat

          • 2. Re: Multiply queue consumers
            magnusw

            Not reallly,

            a Topic deliver the message to all consumers.

            I only wan't the message to be delivered to one consumer but not the same one everytime to get an even load on the consumers.

            I've used a few other JMS servers like Fiorano and OpenJMS and they use a round robin way when having multiply consumers on a queue but it seams like JBoss doesn't.

            • 3. Re: Multiply queue consumers
              weiqingh

              multiple queue receiver semantics is not defined by JMS. (jms spec section 4.4.9). it's up to jms provider to decide what to do. so you shouldn't count on it.

              i am not sure why you need the round-robin behavior. what is the beneifit you are trying to get? if it's load balancing, maybe you can use ejb instead -- having one consumer receiving messages and invoke a clusered SLSB that will process the message.

              or you can use a topic and create multiple MDBs. i am not sure if you would get a round-robin among those MDBs. you can also look into MessageConsumer to see if you can do your own distribution.

              another idea is that if the number of receivers is known, you can have multiple topic subscribers each having a selector (based on its id or something). and then your publisher has to create a message such that each time the message will be selected by only one consumer. it's certainly not elegant...

              • 4. Re: Multiply queue consumers
                celticprince

                I am successfully doing what you are trying. I have multiple message consumers running in client processes. Each of them connect to the same queue, though they each have their own connection, session, queueReceiver, etc. I use a message listener for each, and the process messages in a truly asynchronous manner. I am using JBoss 3.2.3. It works with JBoss 3.2.5 and Weblogic 7.x and 8.x as well.

                Each of my clients are also running in different JVMs (a requirement for what I do with the messages).

                • 5. Re: Multiply queue consumers
                  piperclub

                  when i try having multiple consumers on a queue, and say you send a flood of 1000 messages. Most of them go to one consumer, less than 1% of the messages hit the second consumer.

                  is there a setting somewhere that allows us to balance the load between the consumers available?

                  • 6. Re: Multiply queue consumers

                    Moderated: RTFM

                    Hint: ReceiversImpl

                    • 7. Re: Multiply queue consumers
                      razor_harm

                       

                      "adrian@jboss.org" wrote:
                      Moderated: RTFM

                      Hint: ReceiversImpl


                      Just for the 'searches' on the forum....
                      This is actualy not in the Manual. But it can be found in the WIKI:

                      http://www.jboss.org/wiki/Wiki.jsp?page=JBossMQReceiverImpl



                      • 8. Re: Multiply queue consumers
                        jgc195

                        Sorry - I'm obviously being stupid and missing something obvious but...

                        If I configure my queue to use a different ReceiverImplementation, how do I configure that with x number of consumers?

                        For example - if I had a queue defined as

                         <mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=myQueue">
                         <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
                         <attribute name="ReceiversImpl">
                         org.jboss.mq.server.ReceiversImplArrayList
                         </attribute>
                         </mbean>
                        


                        Where does this list of consumers go? Is it something like this:

                         <mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=myQueue">
                         <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
                         <attribute name="ReceiversImpl" implementation="org.jboss.mq.server.ReceiversImplArrayList">
                         <consumer>server1</consumer>
                         <consumer>server2</consumer>
                         </attribute>
                         </mbean>
                        


                        Or are they hard coded into an implementation of the Receivers interface? Of is this something to do with the DestinationManager?

                        Apologies in advance if this is a really really stupid question...

                        Jason

                        • 9. Re: Multiply queue consumers
                          razor_harm

                           

                          "jgc195" wrote:
                          Sorry - I'm obviously being stupid and missing something obvious but...
                          ....

                          Or are they hard coded into an implementation of the Receivers interface? Of is this something to do with the DestinationManager?

                          Apologies in advance if this is a really really stupid question...

                          Jason


                          The creation of list takes place on runtime. The ReceiverImpl class (implements the Receivers interface) has a method: void add(Subscription sub); Correct me if I'm wrong, but I suspect this method gets called when the consumer registers itself onto the server.




                          • 10. Re: Multiply queue consumers

                             

                            "razor_harm" wrote:
                            Correct me if I'm wrong, but I suspect this method gets called when the consumer registers itself onto the server.


                            You are not wrong. Clients make subscriptions through the normal JMS api.
                            This is just the implementation of the internal datastructure so you can
                            override behaviour like load balancing policy.