activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Fernandez <joe.fernan...@ttmsolutions.com>
Subject Re: PrefetchSize doesn't work.
Date Sun, 06 Jul 2008 05:27:15 GMT

You only have to specify the prefetch policy on the consumer side. 

In Lucas' case, I believe what is happening is that the broker is evenly
distributing the message traffic across the cluster of two consumers,
because the two consumers have the same prefetch value. 

If on the other hand,  you assign one consumer a higher prefetch than the
other, you're giving the broker an indication of which one can handle more
messages. In this case, I think you'll find that the broker will dispatch
more messages to the one with the higher prefetch. 

If you set the prefetch to 0, then I believe the broker will not push/stream
messages out to the synchronous consumer. The consumer has to pull each
message, which is REALLY slow. BTW: prefetch of 0 is not allowed for
asynchronous consumers. 

Joe
www.ttmsolutions.com



Filip Hanik - Dev Lists wrote:
> 
> it works if you specify it on both ends,
> so you have the client correct, on the server you need to specify it too
>             <transportConnector name="openwire" 
> uri="tcp://localhost:61616?maxInactivityDuration=-1&amp;jms.prefetchPolicy.all=1"

> />
> 
> Filip
> 
> fl wrote:
>> Hello,
>>
>> I have trouble with disabling prefetch buffer for consumers. I made
>> simple
>> test.
>>
>> This is my configuration (i tried the same with values = 0): 
>> ConnectionFactory connectionFactory = new
>> ActiveMQConnectionFactory("tcp://localhost:61616?jms.prefetchPolicy.all=1&jms.optimizeMessageDispatch=false");
>> Destination destination = new
>> ActiveMQQueue("queue.TEST?consumer.prefetchSize=1");
>>
>> There is one producer (Producer) and two consumers (ConsumerA,
>> ConsumerB).
>> All consumers and producers are connected to the same queue
>> 'destination'.
>> All consumers and producers are created at begin of the test. So before
>> Producer send a any message, both consumers are ready for receiving
>> messages. MessageConsumer#receive() method is used for receiving.
>>
>> At this point, Producer send 10 messages. Then ConsumerA tries to get as
>> much messages as possible from queue, and it gets 5 messages. Then
>> ConsumerB
>> tries to get as much messages as possible from queue, and it gets 5
>> messages
>> too. 
>> My question is: why ? :)
>>
>> I expected that 9 messages will be consumed by ConsumerA and 1 message by
>> ConsumerB. Instead, its looks like ConsumerB blocks 5 messages for
>> itself,
>> when it should be able to block only one message (according to
>> prefetchSize).
>> I tried various combination with these three parameters showed above and
>> it
>> is always the same behavior.
>>
>> I check 'PrefetchSize' for these subscriptions via JMX console just
>> before
>> any receiving (so there were 10 messages in queue). 
>> 'PrefetchSize' was set to 1 for both subscriptions. It was strange
>> because
>> 'PendingQueueSize' for these subscriptions was set to 4. It looks like 1
>> message in prefetch cache and 4 messages in pending queue gives our 5
>> messages that were blocked by ConsumerB. 
>>
>> And two additional question:
>> 1) 'PendingQueue' - what it actually is ? 
>> 2) Is there any way to set these parameters in xml configuration file? So
>> all ConnectionFactory'ies created without explicitly overwriting will use
>> values from xml.
>>
>> BR,
>> Lucas
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/PrefetchSize-doesn%27t-work.-tp18263153p18299011.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message