You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Rajesh Khan <ra...@gmail.com> on 2012/11/28 22:16:39 UTC

Most optimum receiver - Prefetch how?

I have something like the following code in the receiver. I am currently
dealing with 1000's of messages in perhaps less than 30 seconds.
I read in the broker manual that by default only one message is extracted
by the receiver from the broker however using prefetch I could receive more
than one message at a time.
How can I implement prefetch in my code any suggestions. I read that
setting the count value helps. Is there a way to find out how many messages
the receiver pulls out during each fetch from the broker? How can I
optimize my receiver to receive from queues. Any suggestions would be
appreciated.

C# receiver code.
 while (receiver_n.Fetch(ref message_n, timeout_n))
 {
                    try
                    {
                        message_n.GetContent(content);
                        session.Acknowledge(false); //Not Synchronous
                    }
                    catch (Exception ex)
                    {/*Exception*/}
 }

Re: Most optimum receiver - Prefetch how?

Posted by Rajesh Khan <ra...@gmail.com>.
Thanks for clearing that up

On Thu, Nov 29, 2012 at 7:53 AM, Gordon Sim <gs...@redhat.com> wrote:

> On 11/29/2012 02:48 PM, Rajesh Khan wrote:
>
>> so should i send a session acknowledgment after processing every ten
>> messages or after every message for optimum performance ?
>>
>
> Doing so every 10 messages will improve the throughput as compared with
> doing so every message.
>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.**org<us...@qpid.apache.org>
> For additional commands, e-mail: users-help@qpid.apache.org
>
>

Re: Most optimum receiver - Prefetch how?

Posted by Gordon Sim <gs...@redhat.com>.
On 11/29/2012 02:48 PM, Rajesh Khan wrote:
> so should i send a session acknowledgment after processing every ten
> messages or after every message for optimum performance ?

Doing so every 10 messages will improve the throughput as compared with 
doing so every message.


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


Re: Most optimum receiver - Prefetch how?

Posted by Rajesh Khan <ra...@gmail.com>.
so should i send a session acknowledgment after processing every ten
messages or after every message for optimum performance ?

On Thu, Nov 29, 2012 at 7:28 AM, Gordon Sim <gs...@redhat.com> wrote:

> On 11/29/2012 01:30 PM, Rajesh Khan wrote:
>
>> Thank you for your email and making things a lot clear. However what if I
>> send an asynchronous acknowledgment like
>> session.Acknowledge(false);
>> will it be similar in performance to sending a parameter less
>> acknowledgment.
>>
>
> Yes, because the default value is false (i.e. asynchronous).
>
>
>  Which one will be better for clients that receive high
>> frequency messages?
>>
>
> Asynchronous acknowledgement will lead to higher throughput, so you want
> to stick with that most likely.
>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.**org<us...@qpid.apache.org>
> For additional commands, e-mail: users-help@qpid.apache.org
>
>

Re: Most optimum receiver - Prefetch how?

Posted by Gordon Sim <gs...@redhat.com>.
On 11/29/2012 01:30 PM, Rajesh Khan wrote:
> Thank you for your email and making things a lot clear. However what if I
> send an asynchronous acknowledgment like
> session.Acknowledge(false);
> will it be similar in performance to sending a parameter less
> acknowledgment.

Yes, because the default value is false (i.e. asynchronous).

> Which one will be better for clients that receive high
> frequency messages?

Asynchronous acknowledgement will lead to higher throughput, so you want 
to stick with that most likely.


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


Re: Most optimum receiver - Prefetch how?

Posted by Rajesh Khan <ra...@gmail.com>.
Thank you for your email and making things a lot clear. However what if I
send an asynchronous acknowledgment like
session.Acknowledge(false);
will it be similar in performance to sending a parameter less
acknowledgment. Which one will be better for clients that receive high
frequency messages?

On Thu, Nov 29, 2012 at 3:36 AM, Gordon Sim <gs...@redhat.com> wrote:

> On 11/28/2012 09:16 PM, Rajesh Khan wrote:
>
>> I have something like the following code in the receiver. I am currently
>> dealing with 1000's of messages in perhaps less than 30 seconds.
>> I read in the broker manual that by default only one message is extracted
>> by the receiver from the broker however using prefetch I could receive
>> more
>> than one message at a time.
>> How can I implement prefetch in my code any suggestions.
>>
>
> You just need to set the Capacity property on the receiver to whatever
> size of prefetch you want.
>
>
>  I read that
>> setting the count value helps. Is there a way to find out how many
>> messages
>> the receiver pulls out during each fetch from the broker?
>>
>
> The fetch call returns at most one message. However if prefetch is enabled
> - i.e. if there is a non-zero capacity - then there may already be messages
> on the client available to fetch, without needing to wait for the broker.
> You can get this count through the Available property of the receiver.
>
> [See http://qpid.apache.org/books/**0.18/Programming-In-Apache-**
> Qpid/html/prefetch.html<http://qpid.apache.org/books/0.18/Programming-In-Apache-Qpid/html/prefetch.html>and
> http://qpid.apache.org/books/**0.18/Programming-In-Apache-**
> Qpid/html/ch05s03.html#**id2560547<http://qpid.apache.org/books/0.18/Programming-In-Apache-Qpid/html/ch05s03.html#id2560547>
> ]
>
>
>  How can I
>> optimize my receiver to receive from queues. Any suggestions would be
>> appreciated.
>>
>
> Setting the capacity is the most important one, another is to batch
> acknowledgements if you can e.g. issue the Acknowledge every N messages
> (where N is 10 or something like that).
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.**org<us...@qpid.apache.org>
> For additional commands, e-mail: users-help@qpid.apache.org
>
>

Re: Most optimum receiver - Prefetch how?

Posted by Gordon Sim <gs...@redhat.com>.
On 11/28/2012 09:16 PM, Rajesh Khan wrote:
> I have something like the following code in the receiver. I am currently
> dealing with 1000's of messages in perhaps less than 30 seconds.
> I read in the broker manual that by default only one message is extracted
> by the receiver from the broker however using prefetch I could receive more
> than one message at a time.
> How can I implement prefetch in my code any suggestions.

You just need to set the Capacity property on the receiver to whatever 
size of prefetch you want.

> I read that
> setting the count value helps. Is there a way to find out how many messages
> the receiver pulls out during each fetch from the broker?

The fetch call returns at most one message. However if prefetch is 
enabled - i.e. if there is a non-zero capacity - then there may already 
be messages on the client available to fetch, without needing to wait 
for the broker. You can get this count through the Available property of 
the receiver.

[See 
http://qpid.apache.org/books/0.18/Programming-In-Apache-Qpid/html/prefetch.html 
and 
http://qpid.apache.org/books/0.18/Programming-In-Apache-Qpid/html/ch05s03.html#id2560547]

> How can I
> optimize my receiver to receive from queues. Any suggestions would be
> appreciated.

Setting the capacity is the most important one, another is to batch 
acknowledgements if you can e.g. issue the Acknowledge every N messages 
(where N is 10 or something like that).

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