4 Replies Latest reply on May 6, 2004 1:09 PM by D Rickard

    message distribution round-robining?

    D Rickard Newbie

      I'm running 3.2.4RC2 in the HA configuration with MSSQL persistence on Windows 2000. Our messages are consumed by multi-threaded client apps running outside of JBoss. On each client, all threads share a connection, but each has its own session.

      I was seeing that all messages were being sent to one consumer when the queue depth was <= 1, but they would be sent to multiple consumers if there happened to be more than one message in the queue at once. This is not really a problem, but I was expecting the messages to be round-robin'd to all consumers.

      I read the thread specified here...
      http://www.jboss.org/index.html?module=bb&op=viewtopic&t=48400 ... and went ahead and modified BasicQueue.java to use an ArrayList for the receivers. That seems to have solved my "problem" by round-robining the messages to the various threads and their queue sessions.

      My question is - are there any plans to make the round-robin message delivery functionality the standard algorithm? Or at least make this an optional configuration? Is it already possible to configure message delivery this way and I'm just missing it?

      Thanks,
      -DR

        • 1. Re: message distribution round-robining?
          Elias Ross Master

          I don't really understand how changing the HashSet -> ArrayList really helps distribution of load. It might change the iteration order, but the order then wouldn't change.

          Here's what I think is the problem.

          1. No receivers
          2. Queue receives, say 100 messages
          3. A receiver is added
          When the receiver is added, it gets blasted all 100 messages
          4. Another receiver is added
          5. A message comes in, it goes to the first receiver, the second is ignored. Etc.

          (3) is a hard to solve problem, but at least (5) would be easy enough to fix. It would be a matter of looping the iteration per message. Numbers-wise the load then would be distributed evenly, but not necessarily fairly.

          Why don't we see this with MDB? Because there's one connection with multiple sessions. Multiple connections is probably the cause of this.

          • 2. Re: message distribution round-robining?
            Elias Ross Master


            Ignore what I wrote above. I should just shut up and drink my tea when I haven't taken a good look at the code....

            Every time a message is added, the receiver is removed, and when the receiver is done processing it's added back. For hashtables, objects are returned by an iterator in the order of (Object.hashcode % bucket).

            As it doesn't seem like constant-time access is very much needed, I would recommend changing to a List. However, I would probably use a LinkedList over an ArrayList, because items are removed from the head and added to the tail.

            • 3. Re: message distribution round-robining?
              D Rickard Newbie

              Thanks for the replies.

              By what method can I suggest this as a change to JBossMQ? I didn't want to enter it as a bug since it's not really a bug. I think it makes the most since to make this configurable somehow since for some apps the current message distribution may make sense and for others, round-robin makes sense.

              • 4. Re: message distribution round-robining?
                D Rickard Newbie

                Just found the Submit a Feature Request page http://sourceforge.net/tracker/?func=add&group_id=22866&atid=376688. I guess I should use that!