4 Replies Latest reply on Dec 20, 2012 12:15 PM by bruceas

    In what order does (stand-alone) HornetQ Server distribute messages to multiple clients connected to the same queue?

    bruceas

      I have the following configuration:

      - single, stand-alone HornetQ server

      - single producer client regularly writing messages to a specific queue (e.g. "DEMO_QUEUE")

      - multiple (10) consumer clients consuming messages from this same queue ("DEMO_QUEUE")

       

      Every time the producer sends a message, it is delivered to one (and only one) consumer (as expected).

      For any given message, how does HornetQ determine what particular consumer to send that message to?

       

      In some small tests I've done, it seems that a "round-robin" algorithm (similar to the default one used with clusters) is used (perhaps based on the timing of the various connections?)

      For example, consumer 1 will receive the first message, consumer 2 will receive the second message, consumer 3 the third message, etc;

      After 10 messages are sent, the pattern continues (e.g. consumer 1 receives the 11th message, consumer 2 receives the 12th message, etc. etc).

       

      If there any way to change this pattern? (for example, to deliver any given message to a "random" consumer, instead of the next consumer in line?)

       

      I tried setting the <connection-load-balancing-policy-class-name> to org.hornetq.api.core.client.loadbalance.RandomConnectionLoadBalancingPolicy, but this didn't seem to affect anything (and the documentation suggests that this is only relevant when clusters are used).

       

      Thanks