You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Helen Kwong <he...@gmail.com> on 2014/09/05 21:36:29 UTC

Re: 1 Queue with 2 Consumers - turn off pre-fetching?

Hi Rob,

We're looking into one idea that you suggested, where you said:

> It may be possible to code a client library side change without changing
> the broker (basically reduce consumer credit to 0 as soon as one consumer
> has a message, and release any messages that have been prefetched), but
> that probably isn't a trivial piece of work.

I'm looking at the 0.16 client on 0-10 (which is what we've been using),
and while I couldn't find where the consumer credit is kept track of in the
client code (perhaps this is done on the broker), I did find a method
AMQSession_0_10#sendSuspendChannel() that seems like might solve our
problem. What I'm doing right now is call sendSuspendChannel(true) to
suspend the session's message flow whenever a message listener receives a
message in onMessage(), and then at the end of onMessage(), we call
sendSuspendChannel(false) to resume the message flow. The behavior we've
seen is that when we call sendSuspendChannel(true), it releases the
prefetched messages by this session, so that if another session's consumer
would be able to receive the message.

Do you see any problems with this possible solution? What is the overhead
of suspending and resuming the session each time a listener receives a
message?

Thanks,
Helen


On Fri, Aug 29, 2014 at 5:26 PM, xiaodan.wang <xi...@salesforce.com>
wrote:

> rgodfrey wrote
> > Have you tried the latest trunk revision (or rather any trunk version
> > after
> > http://svn.apache.org/r1621143).  I've made some changes that may (or
> may
> > not) help.  In particular messages that arrive in 0-9-1 in ADDR mode will
> > get ADDR addresses and (hopefully) a type appropriate to their nature.
> >
> > I haven't requested inclusion of this change into 0.30 yet... but let me
> > know if it helps.
>
> Awesome, the latest trunk solved the AMQTopic/Queue issue.
>
> Cheers! Dan
>
>
>
>
> --
> View this message in context:
> http://qpid.2158936.n2.nabble.com/Re-1-Queue-with-2-Consumers-turn-off-pre-fetching-tp6934582p7612835.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>

Re: 1 Queue with 2 Consumers - turn off pre-fetching?

Posted by Rob Godfrey <ro...@gmail.com>.
Hi Helen,

glad to hear you have things working.

The single consumer against multiple queues code is already committed to
trunk, and so will be in 0.32 ... I've not had the chance to do a huge
amount of testing yet, so you might want to play with it a bit before 0.32
gets finalised.  I'm not sure what the release plan for 0.32 is yet - I'd
be quite keen to get another Java release out by the end of the year.


To enable the feature on the broker you currently need to run with
-Dqpid.enableMultiQueueConsumers=true (or you can set it directly as a
"context variable" [1] in the broker configuration).

To consume from such an address you need to use an address string like


ADDR: '' ; {node : { type : queue }, link : { x-subscribe : { arguments : {
x-multiqueue : [ q1, q2, q3 ] } } } }

where q1, q2 and q3 are the queues you wish to consumer from.


If you do get a chance to do any testing and find any issues (or if you
need any help with the upgrading of the configuration of your current
broker to what is now on trunk), please let me know,

Cheers,
Rob


[1]
https://qpid.apache.org/releases/qpid-trunk/java-broker/book/Java-Broker-Management-Managing-Broker.html#Java-Broker-Management-Managing-Broker-Context

On 21 October 2014 00:30, Helen Kwong <he...@gmail.com> wrote:

> Hi Rob,
>
> We have implemented the workaround Dan mentioned before -- by suspending
> the session with sendSuspendChannel() and releasing prefetched messages
> with rejectMessagesForConsumerTag() whenever we detect a long-running
> message -- and so far it is working as expected. Thank you again for all
> your help.
>
> For the long term solution, we plan to upgrade our client and broker to the
> latest version, and use the "single consumer across many queues" feature
> that you're building. So I'm wondering:
> 1. Do you still plan to have this available in v0.32 of Qpid?
> 2. What is the planned release date of v0.32?
>
> Thanks!
>
> Helen
>
> On Tue, Sep 9, 2014 at 12:54 PM, xiaodan.wang <xiaodan.wang@salesforce.com
> >
> wrote:
>
> > Hi Rob, in case you are interested, wanted to give you an update from our
> > side. First, let me begin by saying how awesome the Qpid community has
> > been.
> > Your patience and responsiveness in addressing our questions is way
> beyond
> > what we could have hoped for from this community. I think I speak for
> > Salesforce in saying that we owe you a couple rounds of beer, in case you
> > are ever bored and in San Francisco :)
> >
> > Our plan is to address per-consumer prefetching on the v0.16 clients we
> > currently run in production using the suspend & release prefetched
> messages
> > approach described above. The general flow of our solution is as follows:
> >
> > 1) Each time a message is dispatched and onMessage is invoked, we
> register
> > the parent Qpid session with a session tracker
> >
> > 2)  The session tracker is scheduled every x seconds and looks for Qpid
> > sessions that is processing a long running messages
> >
> > 3) Once the session tracker finds a long running message, it invokes
> > "sendSuspendChannel" and "rejectMessagesForConsumerTag" on the session to
> > suspend dequeue and release any prefetched messages
> >
> > 4) When the long running message is completed, it unregisters the parent
> > Qpid session from the session tracker and invokes "sendSuspendChannel" to
> > resume dequeue
> >
> > We are in the process of performance testing this solution to make sure
> > that
> > a) overhead of suspend and release is manageable and b) no anomalies
> arise
> > from repeatedly suspending and unsuspending the session
> >
> >
> > For our long term plan, we plan to upgrade to the latest version of the
> > client/broker and use the single-consumer-multiple-queue feature you've
> > built in v0.32 for AMQP 0-10. After we've patched our v0.16 client, we
> plan
> > to focus on vetting this.
> >
> > We are also abandoning efforts to switch to per-session prefetch with
> AMQP
> > 0-91. We are grateful for bulk dequeue support in AMQP 0-91, but in
> > subsequent testing, we encountered other incompatibilities due to our use
> > case. (Unfortunately have not had time to dig further). Given that the
> > v0.16
> > band-aid solution eliminated the immediate urgency, we feel that taking
> the
> > time to build a solution around AMQP 0-10 is the right approach going
> > forward.
> >
> > By the way, what is the typical release time frame for Qpid (with
> > v0.32/trunk in mind)?
> > Cheers, Dan
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://qpid.2158936.n2.nabble.com/Re-1-Queue-with-2-Consumers-turn-off-pre-fetching-tp6934582p7613381.html
> > Sent from the Apache Qpid users mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> > For additional commands, e-mail: users-help@qpid.apache.org
> >
> >
>

Re: 1 Queue with 2 Consumers - turn off pre-fetching?

Posted by Helen Kwong <he...@gmail.com>.
Hi Rob,

We have implemented the workaround Dan mentioned before -- by suspending
the session with sendSuspendChannel() and releasing prefetched messages
with rejectMessagesForConsumerTag() whenever we detect a long-running
message -- and so far it is working as expected. Thank you again for all
your help.

For the long term solution, we plan to upgrade our client and broker to the
latest version, and use the "single consumer across many queues" feature
that you're building. So I'm wondering:
1. Do you still plan to have this available in v0.32 of Qpid?
2. What is the planned release date of v0.32?

Thanks!

Helen

On Tue, Sep 9, 2014 at 12:54 PM, xiaodan.wang <xi...@salesforce.com>
wrote:

> Hi Rob, in case you are interested, wanted to give you an update from our
> side. First, let me begin by saying how awesome the Qpid community has
> been.
> Your patience and responsiveness in addressing our questions is way beyond
> what we could have hoped for from this community. I think I speak for
> Salesforce in saying that we owe you a couple rounds of beer, in case you
> are ever bored and in San Francisco :)
>
> Our plan is to address per-consumer prefetching on the v0.16 clients we
> currently run in production using the suspend & release prefetched messages
> approach described above. The general flow of our solution is as follows:
>
> 1) Each time a message is dispatched and onMessage is invoked, we register
> the parent Qpid session with a session tracker
>
> 2)  The session tracker is scheduled every x seconds and looks for Qpid
> sessions that is processing a long running messages
>
> 3) Once the session tracker finds a long running message, it invokes
> "sendSuspendChannel" and "rejectMessagesForConsumerTag" on the session to
> suspend dequeue and release any prefetched messages
>
> 4) When the long running message is completed, it unregisters the parent
> Qpid session from the session tracker and invokes "sendSuspendChannel" to
> resume dequeue
>
> We are in the process of performance testing this solution to make sure
> that
> a) overhead of suspend and release is manageable and b) no anomalies arise
> from repeatedly suspending and unsuspending the session
>
>
> For our long term plan, we plan to upgrade to the latest version of the
> client/broker and use the single-consumer-multiple-queue feature you've
> built in v0.32 for AMQP 0-10. After we've patched our v0.16 client, we plan
> to focus on vetting this.
>
> We are also abandoning efforts to switch to per-session prefetch with AMQP
> 0-91. We are grateful for bulk dequeue support in AMQP 0-91, but in
> subsequent testing, we encountered other incompatibilities due to our use
> case. (Unfortunately have not had time to dig further). Given that the
> v0.16
> band-aid solution eliminated the immediate urgency, we feel that taking the
> time to build a solution around AMQP 0-10 is the right approach going
> forward.
>
> By the way, what is the typical release time frame for Qpid (with
> v0.32/trunk in mind)?
> Cheers, Dan
>
>
>
>
> --
> View this message in context:
> http://qpid.2158936.n2.nabble.com/Re-1-Queue-with-2-Consumers-turn-off-pre-fetching-tp6934582p7613381.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>

Re: 1 Queue with 2 Consumers - turn off pre-fetching?

Posted by "xiaodan.wang" <xi...@salesforce.com>.
Hi Rob, in case you are interested, wanted to give you an update from our
side. First, let me begin by saying how awesome the Qpid community has been.
Your patience and responsiveness in addressing our questions is way beyond
what we could have hoped for from this community. I think I speak for
Salesforce in saying that we owe you a couple rounds of beer, in case you
are ever bored and in San Francisco :)

Our plan is to address per-consumer prefetching on the v0.16 clients we
currently run in production using the suspend & release prefetched messages
approach described above. The general flow of our solution is as follows:

1) Each time a message is dispatched and onMessage is invoked, we register
the parent Qpid session with a session tracker

2)  The session tracker is scheduled every x seconds and looks for Qpid
sessions that is processing a long running messages

3) Once the session tracker finds a long running message, it invokes
"sendSuspendChannel" and "rejectMessagesForConsumerTag" on the session to
suspend dequeue and release any prefetched messages

4) When the long running message is completed, it unregisters the parent
Qpid session from the session tracker and invokes "sendSuspendChannel" to
resume dequeue 

We are in the process of performance testing this solution to make sure that
a) overhead of suspend and release is manageable and b) no anomalies arise
from repeatedly suspending and unsuspending the session


For our long term plan, we plan to upgrade to the latest version of the
client/broker and use the single-consumer-multiple-queue feature you've
built in v0.32 for AMQP 0-10. After we've patched our v0.16 client, we plan
to focus on vetting this.

We are also abandoning efforts to switch to per-session prefetch with AMQP
0-91. We are grateful for bulk dequeue support in AMQP 0-91, but in
subsequent testing, we encountered other incompatibilities due to our use
case. (Unfortunately have not had time to dig further). Given that the v0.16
band-aid solution eliminated the immediate urgency, we feel that taking the
time to build a solution around AMQP 0-10 is the right approach going
forward.

By the way, what is the typical release time frame for Qpid (with
v0.32/trunk in mind)?
Cheers, Dan




--
View this message in context: http://qpid.2158936.n2.nabble.com/Re-1-Queue-with-2-Consumers-turn-off-pre-fetching-tp6934582p7613381.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: 1 Queue with 2 Consumers - turn off pre-fetching?

Posted by "xiaodan.wang" <xi...@salesforce.com>.
Cool beans, we did not set max message delivery attempt or enable DLQ on our
broker :)



--
View this message in context: http://qpid.2158936.n2.nabble.com/Re-1-Queue-with-2-Consumers-turn-off-pre-fetching-tp6934582p7613363.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: 1 Queue with 2 Consumers - turn off pre-fetching?

Posted by Rob Godfrey <ro...@gmail.com>.
To my knowledge the only issue would be if you enabled max message delivery
features, in which case if you reject a message a given number of times
then it will be DLQd... however if you've not enabled that then I don't see
an issue.

 -- Rob


On 9 September 2014 17:35, xiaodan.wang <xi...@salesforce.com> wrote:

> Thanks Rob! The reason I asked is because we are planning to expose/make
> public AMQSession#rejectMessagesForConsumerTag on the v0.16 client that we
> use in production as a short term solution until we upgrade. I see that
> underneath the hood it is calling rejectMessage for each prefetched
> message.
>
> Cheers, Dan
>
>
>
> --
> View this message in context:
> http://qpid.2158936.n2.nabble.com/Re-1-Queue-with-2-Consumers-turn-off-pre-fetching-tp6934582p7613356.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>

Re: 1 Queue with 2 Consumers - turn off pre-fetching?

Posted by "xiaodan.wang" <xi...@salesforce.com>.
Thanks Rob! The reason I asked is because we are planning to expose/make
public AMQSession#rejectMessagesForConsumerTag on the v0.16 client that we
use in production as a short term solution until we upgrade. I see that
underneath the hood it is calling rejectMessage for each prefetched message.

Cheers, Dan



--
View this message in context: http://qpid.2158936.n2.nabble.com/Re-1-Queue-with-2-Consumers-turn-off-pre-fetching-tp6934582p7613356.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: 1 Queue with 2 Consumers - turn off pre-fetching?

Posted by Rob Godfrey <ro...@gmail.com>.
Hi Dan,

messages only get dequeued at the broker when it receives an
acknowledgement for that message... so, no - messages shouldn't get lost in
the case you are describing above.

-- Rob


On 9 September 2014 05:53, xiaodan.wang <xi...@salesforce.com> wrote:

> Hi Rob, when using AMQSession_0_10#sendSuspendChannel(), we noticed that
> existing prefetched messages are not released after suspending the session.
>
> If we were to use AMQSession#rejectMessage(UnprocessMessage message,
> boolean
> reenqueue) to release the message using reenqueue=true, is the message
> guaranteed to be re-delivered? Namely, can the message get lost if the
> client dies after discarding the message but before it is re-enqueued?
>
> Cheers, Dan
>
>
>
> --
> View this message in context:
> http://qpid.2158936.n2.nabble.com/Re-1-Queue-with-2-Consumers-turn-off-pre-fetching-tp6934582p7613337.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>

Re: 1 Queue with 2 Consumers - turn off pre-fetching?

Posted by "xiaodan.wang" <xi...@salesforce.com>.
Hi Rob, when using AMQSession_0_10#sendSuspendChannel(), we noticed that
existing prefetched messages are not released after suspending the session. 

If we were to use AMQSession#rejectMessage(UnprocessMessage message, boolean
reenqueue) to release the message using reenqueue=true, is the message
guaranteed to be re-delivered? Namely, can the message get lost if the
client dies after discarding the message but before it is re-enqueued?

Cheers, Dan



--
View this message in context: http://qpid.2158936.n2.nabble.com/Re-1-Queue-with-2-Consumers-turn-off-pre-fetching-tp6934582p7613337.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: 1 Queue with 2 Consumers - turn off pre-fetching?

Posted by Rob Godfrey <ro...@gmail.com>.
Hi Helen,

that's interesting (and not the way 0-9 works - it doesn't release the
prefetched messages when suspended - so I hadn't actually thought of that
:-)  ).

In terms of overhead, obviously you're going to be doing more work in terms
of re-sending messages over and over again... and the broker will have to
keep resetting the consumer "pointers" into the queues as messages are
released back into the queue... however I guess the only way to determine
if this overhead is significant is for you to test it with your use-case.
 It would certainly make sense if you could somehow determine when you are
processing a long running messages and suspend the session then... if your
message processing would be < 1s then I'd wonder if the work of releasing
all the messages and then having them resent might not dominate the amount
of time actually spent on actual message processing...

It certainly sounds like it might be a workaround for you at the moment
though.

As I said to Dan earlier I'll have a look around the 0-9 codepath to look
at implementing a more sensible mechanism for synchronous sessions with low
prefetch buffers (because this is actually an issue that I've run into
elsewhere).  However it does seem like this might be a lower impact
solution for you if the overhead is not too significant and/or you can
choose to only do this if you determine that you have spent > x seconds
processing the message or something.

-- Rob


On 5 September 2014 21:36, Helen Kwong <he...@gmail.com> wrote:

> Hi Rob,
>
> We're looking into one idea that you suggested, where you said:
>
> > It may be possible to code a client library side change without changing
> > the broker (basically reduce consumer credit to 0 as soon as one consumer
> > has a message, and release any messages that have been prefetched), but
> > that probably isn't a trivial piece of work.
>
> I'm looking at the 0.16 client on 0-10 (which is what we've been using),
> and while I couldn't find where the consumer credit is kept track of in the
> client code (perhaps this is done on the broker), I did find a method
> AMQSession_0_10#sendSuspendChannel() that seems like might solve our
> problem. What I'm doing right now is call sendSuspendChannel(true) to
> suspend the session's message flow whenever a message listener receives a
> message in onMessage(), and then at the end of onMessage(), we call
> sendSuspendChannel(false) to resume the message flow. The behavior we've
> seen is that when we call sendSuspendChannel(true), it releases the
> prefetched messages by this session, so that if another session's consumer
> would be able to receive the message.
>
> Do you see any problems with this possible solution? What is the overhead
> of suspending and resuming the session each time a listener receives a
> message?
>
> Thanks,
> Helen
>
>
> On Fri, Aug 29, 2014 at 5:26 PM, xiaodan.wang <xiaodan.wang@salesforce.com
> >
> wrote:
>
> > rgodfrey wrote
> > > Have you tried the latest trunk revision (or rather any trunk version
> > > after
> > > http://svn.apache.org/r1621143).  I've made some changes that may (or
> > may
> > > not) help.  In particular messages that arrive in 0-9-1 in ADDR mode
> will
> > > get ADDR addresses and (hopefully) a type appropriate to their nature.
> > >
> > > I haven't requested inclusion of this change into 0.30 yet... but let
> me
> > > know if it helps.
> >
> > Awesome, the latest trunk solved the AMQTopic/Queue issue.
> >
> > Cheers! Dan
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://qpid.2158936.n2.nabble.com/Re-1-Queue-with-2-Consumers-turn-off-pre-fetching-tp6934582p7612835.html
> > Sent from the Apache Qpid users mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> > For additional commands, e-mail: users-help@qpid.apache.org
> >
> >
>