You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by yousafsajjad <mu...@dell.com> on 2011/07/21 23:30:11 UTC

Dispatch Policy

Hi,

I am confused with different dispatch policies. There seems to be few
dispatch policies available in activemq along with bunch of properties that
can be changed to achieve different purposes. 

RoundRobin dispatch policy is not working for me. My messages are getting
stuck with the thread that is already busy with working with something
heavy. What dispatch policy along with with settings you believe would be a
good solution and why?

I want such a mechanism that will send the coming message to a free
consumer. I think I can achieve this using simple dispatch, prefetch limit
set to 1 and having few threads. 

What do you think? Any suggestions?

Thanks

--
View this message in context: http://activemq.2283324.n4.nabble.com/Default-Dispatch-Policy-and-Pending-message-Limit-Strategy-tp2365262p3685161.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Dispatch Policy

Posted by yousafsajjad <mu...@dell.com>.
I get an error saying something like: "Illegal prefetch size of zero. This
setting is not supported for asynchronous consumers please set a value of at
least 1"

I am told NOT to make changes in the activemq source code at this stage of
the project. 

Since I am using Spring and I cannot change anything in activemq, is there
any way to change the dispatch policy to process based scheduling of
consumer just by making changes in activemq_broker.xml or any of the
camel/Spring config (bundle-context, bundle-context-camel) files?

or make consumers poll (without actually setting prefetch=0)??

--
View this message in context: http://activemq.2283324.n4.nabble.com/Default-Dispatch-Policy-and-Pending-message-Limit-Strategy-tp2365262p3699587.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Dispatch Policy

Posted by "Martin C." <ma...@gmx.at>.
Hi,

The only issue with Spring's DefaultMessageListenerContainer we have
encountered with prefetch 0 was that the stop() method caused threads
to keep hanging in the DefaultMessageListenerContainer on shutdown,
because the receive(timeout) call of ActiveMQ uses a non-timed-out
read to the broker in this case (i.e. it delegates the timeout to the
broker) for a MessagePull it will never receive as the connection is
stopped. If you are using DefaultMessageListenerContainer, maybe you
can sub-class it and re-implement stop() in a way to wait for all
polling threads to exit before calling connection.stop().

Best regards,
Martin

On Tue, Jul 26, 2011 at 11:15 PM, yousafsajjad <mu...@dell.com> wrote:
> I am not sure whether this will work or not.
>
> I want consumers to poll for messages instead of broker pushing them to
> different consumers in a round robin fashion. I am not able to set prefetch
> limit equal 0 before of Spring framework.
>
> Any ideas that might help asynchronous consumers to poll for messages
> without setting prefetch limit to 0?
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Default-Dispatch-Policy-and-Pending-message-Limit-Strategy-tp2365262p3697021.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Re: Dispatch Policy

Posted by yousafsajjad <mu...@dell.com>.
I am not sure whether this will work or not.

I want consumers to poll for messages instead of broker pushing them to
different consumers in a round robin fashion. I am not able to set prefetch
limit equal 0 before of Spring framework. 

Any ideas that might help asynchronous consumers to poll for messages
without setting prefetch limit to 0?

--
View this message in context: http://activemq.2283324.n4.nabble.com/Default-Dispatch-Policy-and-Pending-message-Limit-Strategy-tp2365262p3697021.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Dispatch Policy

Posted by Gary Tully <ga...@gmail.com>.
use strictOrderDispatch on your queue and use a prefetch that is a
little larger than your expected queue depth.
With these settings, the dispatcher will attempt to fill the first
consumers prefetch buffer with all the messages in order.

When strictOrderDispatch=false, the default, it will round robin
across the available consumers on each dispatch, such that consumer 1
gets message 1, consumer 2 message 2 etc. When true, consumer1 gets
0-prefetch, consumer 2 prefetch-2*prefetch etc.

You can also use consumer priority to have some consumers get the bulk
of messages.
See: consumer.priority from  http://activemq.apache.org/destination-options.html

On 24 July 2011 23:12, swathig <sw...@gmail.com> wrote:
> I'm using ServiceMix and activemq broker to transport messages between
> services deployed in ServiceMix. I'm observing a round robining pattern in
> the order in which activemq chooses the concurrent consumers to push the
> messages to. This seems to be the case even when the prefetch is modified to
> 1. I cannot use a prefetch of 0 since I'm using Spring. I've tried changing
> the dispatch policy to Simple Dispatch in the activemq configuration xml but
> I continue to see the same behavior. Is there any way I can configure
> activemq to push a message to the first available consumer (rather than
> round robin through consumers which I guess is the default out of box
> setting for the version of activemq I'm using)?
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Default-Dispatch-Policy-and-Pending-message-Limit-Strategy-tp2365262p3691134.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



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

Re: Dispatch Policy

Posted by swathig <sw...@gmail.com>.
I'm using ServiceMix and activemq broker to transport messages between
services deployed in ServiceMix. I'm observing a round robining pattern in
the order in which activemq chooses the concurrent consumers to push the
messages to. This seems to be the case even when the prefetch is modified to
1. I cannot use a prefetch of 0 since I'm using Spring. I've tried changing
the dispatch policy to Simple Dispatch in the activemq configuration xml but
I continue to see the same behavior. Is there any way I can configure
activemq to push a message to the first available consumer (rather than
round robin through consumers which I guess is the default out of box
setting for the version of activemq I'm using)?

--
View this message in context: http://activemq.2283324.n4.nabble.com/Default-Dispatch-Policy-and-Pending-message-Limit-Strategy-tp2365262p3691134.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Dispatch Policy

Posted by yousafsajjad <mu...@dell.com>.
Thank you so much for your reply.

I will definitely try it out. 

Just one confusion, can you explain how simple dispatch policy works?
Because I am not able to find much documentation on it. Can you give me a
brief description.

--
View this message in context: http://activemq.2283324.n4.nabble.com/Default-Dispatch-Policy-and-Pending-message-Limit-Strategy-tp2365262p3687149.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Dispatch Policy

Posted by Gary Tully <ga...@gmail.com>.
you may want to use consumer.receive(timeout) on your client and a
prefetch of 0. In this way your client will poll for a single message.
With prefetch of 1, a second message will be cached on the consumer
while the first is pending.

On 21 July 2011 22:30, yousafsajjad <mu...@dell.com> wrote:
> Hi,
>
> I am confused with different dispatch policies. There seems to be few
> dispatch policies available in activemq along with bunch of properties that
> can be changed to achieve different purposes.
>
> RoundRobin dispatch policy is not working for me. My messages are getting
> stuck with the thread that is already busy with working with something
> heavy. What dispatch policy along with with settings you believe would be a
> good solution and why?
>
> I want such a mechanism that will send the coming message to a free
> consumer. I think I can achieve this using simple dispatch, prefetch limit
> set to 1 and having few threads.
>
> What do you think? Any suggestions?
>
> Thanks
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Default-Dispatch-Policy-and-Pending-message-Limit-Strategy-tp2365262p3685161.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



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