简体   繁体   English

模块集群和JMS

[英]Module clustering and JMS

I have a module which runs standalone in a JVM (no containers) and communicates with other modules via JMS . 我有一个在JVM (没有容器)中独立运行并通过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. 然后,出于HA和工作量方面的原因,我需要对该模块进行群集,并且我可能要与Terracotta + Hibernate一起对我的实体进行群集。 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). 当前,当我的应用程序启动时,它会启动一个线程(通过Executors.newSingleThreadExecutor() )作为使用者(我可以在必要时附加实际代码示例)。

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. 我在这里读书的问题理解的是,如果我刚开始我的模块上N不同JVMs然后N不同的用户将被创建在队列中的每个消息将到达N用户。 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. 我想做的是只处理其中的一条消息(目前,让我们说哪个不重要),因此实际上使我能够一次处理N消息。

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. 顺便说一句,我正在使用OpenMQ作为实现,但是我不知道这是否有意义。

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 . 看一下JGroups You may consider implementing your module/subscribers to use jgroups for the kind of synchronization you need. 您可以考虑实现模块/订户以使用jgroup进行所需的同步。 JGroups provide Reliable Multicast Communication. JGroups提供可靠的多播通信。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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