简体   繁体   中英

Module clustering and JMS

I have a module which runs standalone in a JVM (no containers) and communicates with other modules via JMS . My module is both a producer in one queue and a consumer in a different queue. I have then need to cluster this module, both for HA reasons and for workload reasons, and I'm probably going to go with Terracotta+Hibernate for clustering my entities. Currently when my app starts it launches a thread (via Executors.newSingleThreadExecutor() ) which serves as the consumer (I can attach actual code sample if relevant and neccessary).

What I understood from reading questions here is that if I just start up my module on N different JVMs then N different subscribers will be created and each message in the queue will arrive to N subscribers. What I'd like to do is have only one of them (let's currently say that which one is not important) process that message and so in actuality enable me to process N messages at a time.

How can/should this be done? Am I way off the track?

BTW, I'm using OpenMQ as my implementation but I don't know if that's relevant.

Thanks for any help

A classic case of message handling in clustered environment. This is what I would do.

Use Broadcast message (Channel based) in place of Queue. Queue being useful for point to point communication is not very effective. Set validity of message till the time it is consumed by one of the consumer. This way, other consumers wont even see the message and only one consumer will consume it.

Take a look at JGroups . You may consider implementing your module/subscribers to use jgroups for the kind of synchronization you need. JGroups provide Reliable Multicast Communication.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM