activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Bain <tb...@alumni.duke.edu>
Subject Re: Prefetch, message consumer async listener and message grouping, transactions & clustering - how does it work?
Date Mon, 21 Sep 2015 02:53:55 GMT
OK, so I'm assuming then that your actual question relates to the situation
where both consumers are already connected when the first message is sent,
since you just demonstrated that you know what happens when messages are
sent when only one consumer is connected and since the same thing happens
when there are messages queued and the first consumer connects.  (The other
situation, where messages are queued and then both consumers connect
simultaneously, is pretty unlikely in practice in most cases, so I assume
that's not what you're asking about.)

In that scenario, message 1 arrives and is dispatched to consumer 1,
resulting in a rotation of the consumer list (so consumer 2 is first).
Message 2 arrives and is determined not to be dispatchable to consumer 2,
so it's dispatched to consumer 1 as long as prefetch > 1 (otherwise it's
skipped, to be re-dispatched later).  If we follow the path where prefetch
= 5, we'll dispatch the message to consumer 2 and rotate the list again,
putting consumer 1 at the front.  Message 3 arrives and can be dispatched
to consumer 1, so it is, which locks both message groups to consumer 1,
causing messages 4 and 5 to be dispatched to consumer 1, after which no
messages can be dispatched until consumer 1 acks some messages.  Consumer 2
gets no messages and does no work, and your statement that all messages
from message group 1 get prefetched to consumer 1 isn't accurate (because
it can only hold 5 messages).

If we follow the other thread (prefetch = 1), message 2 is skipped, so
there is no rotation of the consumer list.  So when message 3 arrives,
consumer 2 is first in the list, and message 3 is dispatched to it.  Then
both consumers are full, so no further messages are dispatched to either
one till one of them acks their message.

So the question of who gets which message group in your scenario depends on
the ordering of the messages as well as whether consumers are able to
accept messages or are full.  As in many things, it depends.

As far as the question about redelivery order, redelivery is typically
handled on the consumer to preserve message ordering.  So if processing
failed for message 4, the consumer would attempt to re-process it again
until it was sent to the DLQ.  However, as of 5.7 there is the option to
allow the broker to perform redelivery by re-sending the message, which
puts it at the back of the queue and results in out-of-order message
delivery (possibly to a different consumer, though not in the case of
message groups); see to bottom of
http://activemq.apache.org/message-redelivery-and-dlq-handling.html.

Tim

On Sat, Sep 19, 2015 at 11:44 AM, sburczymucha <sburczymuchatefek@gmail.com>
wrote:

> Hello,
>
> That depends, I can't guarantee that both consumers will be connected. In
> worst case scenario only one consumer will be connected, and will consume
> messages with JMSXGroupID = 1 then with JMSXGroupID = 2 (because client is
> sending JMSXGroupID=-1 every X messages).
>
> Best Regards,
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Prefetch-message-consumer-async-listener-and-message-grouping-transactions-clustering-how-does-it-wo-tp4702096p4702101.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message