You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Torsten Mielke <to...@fusesource.com> on 2011/09/01 17:34:20 UTC

Re: Consumer wait for next batched messages for several seconds?

you quickly does the consumer process the 1000 msgs and how fast is the network between broker and consumer?
What's the size of the msg? Is the consumer session transacted?

In general the broker can prefetch more msgs to your consumer once the consumer has acked a few msgs. So the broker should try to keep the consumers prefetch full (assuming there are more msgs on the queue to dispatch). The broker generally does not wait for all the 1000 msgs to be acked, before dispatching more msgs.


Torsten Mielke
torsten@fusesource.com
tmielke@blogspot.com




Reply:Reply:Re: How does message acknowledge reply to broker when session is transacted?

Posted by SuoNayi <su...@163.com>.
I'm sorry I ignore  NOT operator before method named isAutoAcknowledgeBatch.
This make me confused for one day just because I'm so careless  to ignore the important operator NOT.
Thanks Gary.

At 2011-09-08 09:21:04,SuoNayi <su...@163.com> wrote:
>Gary,thanks for your quick reply.I have read source code again,session will dispatch message to consumer with the method dispatch(Line1216).
>beforeMessageIsConsumed will be invoked before messages are consumed and afterMessageIsConsumed will be invoked after messages are consumed.
>But no ackLater is not involved because session is transacted and acknowledgementMode is auto.
>
>At 2011-09-08 01:14:54,"Gary Tully" <ga...@gmail.com> wrote:
>>there is a synchronization registered with the transaction and the ack
>>is sent in a beforeEnd callback when the transaction commits.
>>see: org.apache.activemq.ActiveMQMessageConsumer#ackLater
>>
>>2011/9/7 SuoNayi <su...@163.com>:
>>> Hi all,how does message acknowledge reply to broker when session is transacted?
>>>
>>> I have read the source code but found nothing to do if session is transacted after messages are consumed.
>>>
>>> Thanks.
>>
>>
>>
>>-- 
>>http://fusesource.com
>>http://blog.garytully.com

Reply:Re: How does message acknowledge reply to broker when session is transacted?

Posted by SuoNayi <su...@163.com>.
Gary,thanks for your quick reply.I have read source code again,session will dispatch message to consumer with the method dispatch(Line1216).
beforeMessageIsConsumed will be invoked before messages are consumed and afterMessageIsConsumed will be invoked after messages are consumed.
But no ackLater is not involved because session is transacted and acknowledgementMode is auto.

At 2011-09-08 01:14:54,"Gary Tully" <ga...@gmail.com> wrote:
>there is a synchronization registered with the transaction and the ack
>is sent in a beforeEnd callback when the transaction commits.
>see: org.apache.activemq.ActiveMQMessageConsumer#ackLater
>
>2011/9/7 SuoNayi <su...@163.com>:
>> Hi all,how does message acknowledge reply to broker when session is transacted?
>>
>> I have read the source code but found nothing to do if session is transacted after messages are consumed.
>>
>> Thanks.
>
>
>
>-- 
>http://fusesource.com
>http://blog.garytully.com

Re: How does message acknowledge reply to broker when session is transacted?

Posted by Gary Tully <ga...@gmail.com>.
there is a synchronization registered with the transaction and the ack
is sent in a beforeEnd callback when the transaction commits.
see: org.apache.activemq.ActiveMQMessageConsumer#ackLater

2011/9/7 SuoNayi <su...@163.com>:
> Hi all,how does message acknowledge reply to broker when session is transacted?
>
> I have read the source code but found nothing to do if session is transacted after messages are consumed.
>
> Thanks.



-- 
http://fusesource.com
http://blog.garytully.com

How does message acknowledge reply to broker when session is transacted?

Posted by SuoNayi <su...@163.com>.
Hi all,how does message acknowledge reply to broker when session is transacted?

I have read the source code but found nothing to do if session is transacted after messages are consumed.

Thanks.

Reply:Re: Reply:Re: Consumer wait for next batched messages for several seconds?

Posted by SuoNayi <su...@163.com>.
Torsten,I'm sure there is no problem with my network.
Setting optimizeAcknowledge  to be false then messages dispatched to consumer by broker come continuously.
So I guess that consumer give no enough pull command to broker when Setting optimizeAcknowledge  to be true.
With thinking about this,I reset optimizeAcknowledge  to be true and set prefetchSize to be 300 (default 1000) and it works!resetting prefetchSize to be 500, 400 does not work again.So when prefetchSize to be 300 consumer give applicable pull to broker and messages dispatched to consumer by broker never breaks anymore.
It seems there is some relationship with message size ,disk read speed, buffer size and so on.
 

At 2011-09-02 20:57:55,"Torsten Mielke" <to...@fusesource.com> wrote:
>From http://activemq.apache.org/performance-tuning.html
>using optimizedAcknowledge will ack all outstanding msgs after either 300ms or 65% of the prefetch (650 msgs in your case).
>
>With such setting and given your use case, it should not take several seconds before new msgs are dispatched to the broker. 
>Have you tried running the same test locally (with broker and producer/consumer) on the same physical machine? I wonder if that gets you different results.
>If all works fine locally, then its something with your network. 
>If you see the same problem when running locally, perhaps try to reproduce the issue using one of the ActiveMQ demos.
>If you can't reproduce it there, it probably something in your application that causes this. 
>
>If you have a simple reproducible test case, we could have a look.
>
>Regards,
>Torsten
>
>
>
>On Sep 2, 2011, at 4:47 AM, SuoNayi wrote:
>
>> Yes, messageListener of the only one consumer only prints the message on console .
>> The size of message is only 1kb.
>> Consumer and broker is in the same LAN(100m).
>> The consumer session is not transacted but I have set optimizeAcknowledge to be true.
>> The break when consumer wait for next buffered messages takes several seconds, this  isreasonable or not?
>> 
>> At 2011-09-01 23:34:20,"Torsten Mielke" <to...@fusesource.com> wrote:
>>> you quickly does the consumer process the 1000 msgs and how fast is the network between broker and consumer?
>>> What's the size of the msg? Is the consumer session transacted?
>>> 
>>> In general the broker can prefetch more msgs to your consumer once the consumer has acked a few msgs. So the broker should try to keep the consumers prefetch full (assuming there are more msgs on the queue to dispatch). The broker generally does not wait for all the 1000 msgs to be acked, before dispatching more msgs.
>>> 
>>> 
>>> Torsten Mielke
>>> torsten@fusesource.com
>>> tmielke@blogspot.com
>>> 
>>> 
>>> 
>
>Torsten Mielke
>torsten@fusesource.com
>tmielke@blogspot.com
>
>
>

Re: Reply:Re: Consumer wait for next batched messages for several seconds?

Posted by Torsten Mielke <to...@fusesource.com>.
From http://activemq.apache.org/performance-tuning.html
using optimizedAcknowledge will ack all outstanding msgs after either 300ms or 65% of the prefetch (650 msgs in your case).

With such setting and given your use case, it should not take several seconds before new msgs are dispatched to the broker. 
Have you tried running the same test locally (with broker and producer/consumer) on the same physical machine? I wonder if that gets you different results.
If all works fine locally, then its something with your network. 
If you see the same problem when running locally, perhaps try to reproduce the issue using one of the ActiveMQ demos.
If you can't reproduce it there, it probably something in your application that causes this. 

If you have a simple reproducible test case, we could have a look.

Regards,
Torsten



On Sep 2, 2011, at 4:47 AM, SuoNayi wrote:

> Yes, messageListener of the only one consumer only prints the message on console .
> The size of message is only 1kb.
> Consumer and broker is in the same LAN(100m).
> The consumer session is not transacted but I have set optimizeAcknowledge to be true.
> The break when consumer wait for next buffered messages takes several seconds, this  isreasonable or not?
> 
> At 2011-09-01 23:34:20,"Torsten Mielke" <to...@fusesource.com> wrote:
>> you quickly does the consumer process the 1000 msgs and how fast is the network between broker and consumer?
>> What's the size of the msg? Is the consumer session transacted?
>> 
>> In general the broker can prefetch more msgs to your consumer once the consumer has acked a few msgs. So the broker should try to keep the consumers prefetch full (assuming there are more msgs on the queue to dispatch). The broker generally does not wait for all the 1000 msgs to be acked, before dispatching more msgs.
>> 
>> 
>> Torsten Mielke
>> torsten@fusesource.com
>> tmielke@blogspot.com
>> 
>> 
>> 

Torsten Mielke
torsten@fusesource.com
tmielke@blogspot.com




Reply:Re: Consumer wait for next batched messages for several seconds?

Posted by SuoNayi <su...@163.com>.
Yes, messageListener of the only one consumer only prints the message on console .
The size of message is only 1kb.
Consumer and broker is in the same LAN(100m).
The consumer session is not transacted but I have set optimizeAcknowledge to be true.
The break when consumer wait for next buffered messages takes several seconds, this  isreasonable or not?

At 2011-09-01 23:34:20,"Torsten Mielke" <to...@fusesource.com> wrote:
>you quickly does the consumer process the 1000 msgs and how fast is the network between broker and consumer?
>What's the size of the msg? Is the consumer session transacted?
>
>In general the broker can prefetch more msgs to your consumer once the consumer has acked a few msgs. So the broker should try to keep the consumers prefetch full (assuming there are more msgs on the queue to dispatch). The broker generally does not wait for all the 1000 msgs to be acked, before dispatching more msgs.
>
>
>Torsten Mielke
>torsten@fusesource.com
>tmielke@blogspot.com
>
>
>