You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by geenee1019 <ge...@gmail.com> on 2009/06/22 12:47:32 UTC

Load Balancing in ActiveMQ

Hi,

Could anyone let me know how to do configure load balancing in Active MQ.... 

My requirement in For example if a queue has received 5 messages means the
next 5 messages has to be routed to another queue and so on.... 

I was successfully able to achieve the failover scenario i.e if a queue
fails, the message will be routed to other queue...Now I want to know about
load balancing. 


Thanks....
-- 
View this message in context: http://www.nabble.com/Load-Balancing-in-ActiveMQ-tp24145146p24145146.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Load Balancing in ActiveMQ

Posted by bwtaylor <br...@yahoo.com>.
A queue with multiple competing consumers IS a form of load balancing, so the
answer to what you are trying to do is probably simpler than you expect.
Refer to the  http://activemq.apache.org/clustering.html clustering  page.
Competing consumers on a queue will vie for messages, each taking up to the
prefetch limit, processing them, and acknowledging them back to the broker.
If the consumer dies having taken but not ack'd messages, they are
(eventually) thrown back onto the queue and can be taken by other consumers.
So probably you need only one queue, not several here. You can even leverage
affinity by using  http://activemq.apache.org/message-groups.html message
groups .

I'm not sure I understand your conern about "if a queue fails". The entire
broker would likely fail as a unit with its JVM and take all of its queues
with it. If by this you meant you want greater HA reliability, then you want
to be using some kind of master/slave broker cluster. If the master fails,
the slave will take over, picking up queues and topics in the same state the
master had when it failed. Producers and consumers would have to implement 
http://activemq.apache.org/failover-transport-reference.html failover  in
this case, which is easy. If you don't use master/slave, then when the JVM
running a broker with your queue dies, your persistent messages will still
be there when it comes back up, however long that takes, while your
non-persistent messages are lost.


geenee1019 wrote:
> 
> Hi,
> 
> Could anyone let me know how to do configure load balancing in Active
> MQ.... 
> 
> My requirement in For example if a queue has received 5 messages means the
> next 5 messages has to be routed to another queue and so on.... 
> 
> I was successfully able to achieve the failover scenario i.e if a queue
> fails, the message will be routed to other queue...Now I want to know
> about load balancing. 
> 
> 
> Thanks....
> 

-- 
View this message in context: http://www.nabble.com/Load-Balancing-in-ActiveMQ-tp24145146p24178063.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Load Balancing in ActiveMQ

Posted by Bruce Snyder <br...@gmail.com>.
2009/6/22 lzr <js...@163.com>:
> Try this way:
>
> Three brokers: b1, b2 and b3; with Queue named q1;
> Config networkConnectors from b1 to b2 and b3;
> For the Queue q1, run consumer application on b2 and b3; The messages put into q1 will be dispatched to b2 and b3 in same weight.
>
> I tried this configuration and found it worked well.

This is a network of brokers:

http://activemq.apache.org/networks-of-brokers.html

In a network of brokers, messages are not load balanced across the
brokers. However, by default, ActiveMQ uses a round robin dispatch
policy so that active consumers on a destination get an equal
distribution of messages. Messages are distributed across the brokers
based on demand from active consumers on q1 on each broker. But note
that if there are no consumers on q1 on a given broker, messages will
not be distributed there.

Additionally, each consumer's prefetch limit will play a part in
message distribution as well:

http://activemq.apache.org/what-is-the-prefetch-limit-for.html

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

ActiveMQ in Action: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder

Re:Load Balancing in ActiveMQ

Posted by lzr <js...@163.com>.
Try this way:
 
Three brokers: b1, b2 and b3; with Queue named q1;
Config networkConnectors from b1 to b2 and b3;
For the Queue q1, run consumer application on b2 and b3; The messages put into q1 will be dispatched to b2 and b3 in same weight.
 
I tried this configuration and found it worked well.
 
Good luck,
Zhuran Li




在2009-06-22,geenee1019 <ge...@gmail.com> 写道:
>
>Hi,
>
>Could anyone let me know how to do configure load balancing in Active MQ.... 
>
>My requirement in For example if a queue has received 5 messages means the
>next 5 messages has to be routed to another queue and so on.... 
>
>I was successfully able to achieve the failover scenario i.e if a queue
>fails, the message will be routed to other queue...Now I want to know about
>load balancing. 
>
>
>Thanks....
>-- 
>View this message in context: http://www.nabble.com/Load-Balancing-in-ActiveMQ-tp24145146p24145146.html
>Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>