activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: Implementing prefetchSize=0
Date Wed, 09 Aug 2006 07:48:48 GMT
Note that to implement the JMS API - the minimum value of prefetch
possible is 1 which means deliver 1 message then wait until an
acknowledgement before delivering another. This is essential to


Neither of which are possible to implement with a prefetch of zero
which effectively means you cannot dispatch messages to the consumers
at all - they must pull them on demand.

We could implement the method consumer.receive() to block and
explicitly perform a request-response to the broker pulling a message.
With a bit more thought we might figure out a way of implementing
receive(timeout) where if a message is delivered by the broker after
the timeout we give it back to the broker.

Though i"m with Hiram on this one - I don't think a prefetch of zero
is really needed. Also note that receive() wouldn't solve your use
case since it would deliver you a message on the requested queue
anyway. What you really want is 'receive a message if you can on queue
1, then if not on queue2 then if not on queue 3' which is quite
different to a prefetch of zeron.

You'd be better creating a single consumer which consumes to all 3
queues using a wildard or composite destination or even just a single
queue. Then you might want to create your own DispatchPolicy to decide
which messages get dispatched to which consumers - or write some
reordering logic in a Broker Interceptor to make sure that any 'big
jobs' are reordered to be ahead of any 'small jobs' by waiting a small
amount of time to see if you can reorder things.

i.e. what you really want to do is just reorder messages on a queue
based on their priority. Even if we had a prefetch of zero I don't
think it'll help you much.

On 8/8/06, Pesochinskiy, Vadim (MSCIBARRA)
<> wrote:
> Hi!
> I am trying to figure out how this can be done.
> As I understand messages are forwarded by the queue to every consumer
> (PrefetchSubscription). As long as number of messages dispatched does
> not exceed the prefetchSize, messages are send to the client. As soon as
> messages are acked more messages are dispatched to the client.
> When I set prefetchSize=0 no messages are ever delivered. In this case
> instead of pushing messages from the server, they will have to be
> requested by the client every time receive() or receiveNoWait() is
> called. Are you OK with this impelementation?
> BTW, are you guys convinced that AMQ-855 is an issue that needs to be
> resolved? To remind you, I need multiple consumers to implement our
> prioriteis requirements. In some cases consumers maybe be idle for a
> long time and as a result they hold real-time messages, which otherwise
> could to be processed by other consumers.
> --------------------------------------------------------
> NOTICE: If received in error, please destroy and notify sender. Sender does not intend
to waive confidentiality or privilege. Use of this email is prohibited when received in error.



View raw message