Load balancing MessageQ (ActiveMQ)

2019-09-01 14:14发布

This is my scenario..

1) A REST based web service (Say X) takes in requests and puts it into ActiveQ 2) There is a listener on the other side of the Q that will read and process the message. This is async

I decided to go with ActiveMQ. But trying to find a solution where I can Q and the Q listeners scalable.

1) I have many instances of X running. Hence there are multiple prodders to the Q. 2) Ordering is important to me. 3) Since my REST service is session less, I don't have a way to tag a bunch of requests with the same message ID. 4) Now if I use a single Q, it works fine..

But I want to scale it up and use multiple Q and multiple Q consumers without compromising on the order.

Can someone suggest me a solution to this problem?

Thanks much,

2条回答
Animai°情兽
2楼-- · 2019-09-01 14:25

We can use following kind of connection URL to utilize ActiveMQ load....

failover://(tcp://192.nnn.nn.nn:61616,tcp://192.nnn.nn.nn:61616)?randomize=false

randomize=true will made message shuffles between two AciveMQ in active mode, rather not by just fail-over of ActiveMQ......

Complete reference for this can be found under the following Apache Site link....

http://activemq.apache.org/failover-transport-reference.html

But Still high availability (i.e, cluster) configuration make things stable for your App although Apache must advance ActiveMQ High Availability, hence things can work smoother.

Although because of KahaDB restriction load balancing/fault tolerant configuration is restricted. The present Apache ActiveMQ High Availability configuration available in the following link.

http://activemq.apache.org/clustering.html

However KahaDB has file lock restriction, following tweaking/alternates ways of configuration can be done...

1)Shared File System Master Slave,- A shared file system such as a SAN http://activemq.apache.org/shared-file-system-master-slave.html

2)JDBC Master Slave,- A Shared database http://activemq.apache.org/jdbc-master-slave.html

3)Replicated LevelDB Store,- ZooKeeper Server http://activemq.apache.org/replicated-leveldb-store.html

Over & above by having JCA connectors,- AS like JBoss, Weblogic, Websphere, Geronimo, Glassfish,- ActimeMQ patching as a kind of Resource Adapter can be done. And with Apache Camel (karaf), JBoss Fuse ESB kind of products HA & clustering of ActiveMQ can be done.

查看更多
唯我独甜
3楼-- · 2019-09-01 14:34

To achieve ordering of messages there are 2 ways defined in activeMQ

1)MessageGroups based on JMSXGroupID

2)Exclusive Consumer

Message groups are more useful than Exclusive consumer,as internally Exclusive Consumer only uses one consumer at a time,but in case of that consumer failure it connects to other consumer.

You can read the ActiveMQ documentation for the same here

hope this helps! Good luck!

查看更多
登录 后发表回答