You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Partha Sarathy Maripini <pm...@salesforce.com.INVALID> on 2024/09/04 09:11:58 UTC
Unexpected behaviour with one queue and two consumers from different sessions.
Hi,
I'm using qpid-jms-client 2.4.0 with qpid-proton-j 0.34.1 and qpid-broker-j
v7.0.9.
I set up an experiment using qpid-jms-client(2.4.0) to use asynchronous
message delivery with a transacted session, and configured the client’s
prefetch count to 1. The test involved two sessions (A and B) and two
queues (Q1 and Q2). Each session has two consumers, one for Q1 and one for
Q2. I'd sent two messages: a long-running one to Q1 and a short-running one
to Q2. A consumer in session A processes the long-running message from Q1.
Meanwhile, session B does not process the short-running message on Q2, even
though it remains unconsumed. Once session A finishes with the long-running
message, it then proceeds to consume the message from Q2.
I was aware that this behavior was characteristic of the older Qpid v0.16
client, where the method AMQSession_0_10#sendSuspendChannel() addressed the
issue. By calling sendSuspendChannel(true), the session's message flow is
suspended whenever a message listener receives a message in onMessage(). At
the end of onMessage(), sendSuspendChannel(false) is called to resume the
message flow. This approach was effective because calling
sendSuspendChannel(true) releases the prefetched messages held by the
session, allowing another session's consumer to receive those messages.
Additionally, the method AMQSession#rejectMessagesForConsumerTag was made
public in the v0.16 client and was used as a temporary fix in production
until we upgraded to the current client version. I observed that this
method internally calls rejectMessage for each prefetched message.
I’m now upgrading to the latest client, which uses AMQP 1.0, and am
encountering the same issue as before. Are there alternative methods to
address this problem, and could you suggest any long-term solutions?
Please find the reference to a 10 years old conversation :-)
https://www.mail-archive.com/users@qpid.apache.org/msg10326.html
Regards,
Partha
Re: Unexpected behaviour with one queue and two consumers from different sessions.
Posted by Robbie Gemmell <ro...@gmail.com>.
This shouldnt be particularly unexpected behaviour given it is exactly
the same effective scenario as you encountered before, with the same
causes stemming from both your specific application behaviour and
general protocol behaviour. It is not in any way specific to the 0.16
AMQP-0-10 client
AMQP 1.0 grants credit per-consumer, just as AMQP 0-10 did. You are
using asynchronous MessageListener consumers, which must always grant
a credit for a message to arrive so that any ever will (whilst a
no-prefetch synchronous consumer could only grant credit whilst you
ask it for a message). You then create multiple such listeners on the
same Session, knowing they must all be served by a session-level
single threaded sequential delivery sequence as per JMS requirement.
You are then mixing consumers for 'long running' and 'short running'
messages in the same session, even though you specifically care that
the 'long running' ones do not hold up the 'short running' one being
processed by a different Session's consumers, which cant happen if it
gets sent to the created-and-waiting async consumer on the same
Session as the already-processing long-running message as you
requested it be by creating the async consumers on the same Session.
The obvious choices would seem to be:
a) Seperate your listener consumers into their own Sessions so they
each have their own async delivery thread and thus the different
consumers message delivery isnt linked.
b) Use synchronous consumers with 0-prefetch so no messages are ever
sent to a consumer that isnt being actively asked for such a message
(something you'd then need to do in your application code).
You could try hacking the 1.0 client to do unintended things to
compensate, as you have for the old 0-10 client, though I expect you
will find that more awkward this time around since its JMS and
AMQP-handling innards are much more segmented into separate layers.
It won't help here at all, but note you can specify a prefetch of 0
rather than 1, even when using async listener consumers. For
listener-based consumers, a '0-prefetch' and '1-prefetch' will behave
the same (whereas for sync consumers they'd behave very differently,
hence this note) where it will grant 1 credit up front at creation,
then grant a replacement credit after onMessage returns such that
another message can actually be consumed.
On Wed, 4 Sept 2024 at 10:14, Partha Sarathy Maripini
<pm...@salesforce.com.invalid> wrote:
>
> Hi,
>
> I'm using qpid-jms-client 2.4.0 with qpid-proton-j 0.34.1 and qpid-broker-j
> v7.0.9.
>
> I set up an experiment using qpid-jms-client(2.4.0) to use asynchronous
> message delivery with a transacted session, and configured the client’s
> prefetch count to 1. The test involved two sessions (A and B) and two
> queues (Q1 and Q2). Each session has two consumers, one for Q1 and one for
> Q2. I'd sent two messages: a long-running one to Q1 and a short-running one
> to Q2. A consumer in session A processes the long-running message from Q1.
> Meanwhile, session B does not process the short-running message on Q2, even
> though it remains unconsumed. Once session A finishes with the long-running
> message, it then proceeds to consume the message from Q2.
>
> I was aware that this behavior was characteristic of the older Qpid v0.16
> client, where the method AMQSession_0_10#sendSuspendChannel() addressed the
> issue. By calling sendSuspendChannel(true), the session's message flow is
> suspended whenever a message listener receives a message in onMessage(). At
> the end of onMessage(), sendSuspendChannel(false) is called to resume the
> message flow. This approach was effective because calling
> sendSuspendChannel(true) releases the prefetched messages held by the
> session, allowing another session's consumer to receive those messages.
> Additionally, the method AMQSession#rejectMessagesForConsumerTag was made
> public in the v0.16 client and was used as a temporary fix in production
> until we upgraded to the current client version. I observed that this
> method internally calls rejectMessage for each prefetched message.
>
> I’m now upgrading to the latest client, which uses AMQP 1.0, and am
> encountering the same issue as before. Are there alternative methods to
> address this problem, and could you suggest any long-term solutions?
>
> Please find the reference to a 10 years old conversation :-)
> https://www.mail-archive.com/users@qpid.apache.org/msg10326.html
>
> Regards,
> Partha
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org