简体   繁体   English

为Java客户端实现故障转移模式的最佳方法

[英]Best way to implement Failover Pattern for Java Clients

We are designing a Java client (will be deployed on Tomcat, Windows 2008 R2) which needs to subscriber for some JMS topics on Sonic MQ. 我们正在设计一个Java客户端(将在Tomcat,Windows 2008 R2上部署),该客户端需要订阅一些Sonic MQ上的JMS主题。

Client wants to have to redundancy for this Java client and at any point of time, only one subscriber should be subscribed for topics. 客户端希望为此Java客户端提供冗余,并且在任何时间点,仅一个订阅者应订阅主题。

Our requirement is similar to the this post . 我们的要求与此职位相似。

Is there's any standardized open source project which is built for this purpose or we have to write our own code to check the server health (time-consuming)? 是否为此目的构建了任何标准化的开源项目,还是我们不得不编写自己的代码来检查服务器的运行状况(耗时)? What's the best way to implement this Java Client. 实现此Java客户端的最佳方法是什么。

We are exploring the below technologies for consuming JMS messages: 我们正在探索以下用于消耗JMS消息的技术:

  • Spring Integration 春季整合
  • Apache Camel 阿帕奇骆驼

Are we going in the right direction? 我们朝着正确的方向前进吗? We should be able to start/stop the subscriptions to the topics on fly. 我们应该能够即时启动/停止对主题的订阅。

Apache Camel have something like this out of the box check this . Apache Camel开箱即用就可以 It implements EAI Load Balancer pattern. 它实现了EAI负载均衡器模式。 You can choose "Failover" Policy. 您可以选择“故障转移”策略。 seems to be using Exception to decide which processor to go next. 似乎正在使用Exception来决定下一步要使用的处理器。

Other way to do can be to implement simple custom jms based hearbeats among subscribers to keep track of each other health and balance load or failover. 其他方法可以是在订户之间实施基于简单自定义jms的听音,以相互跟踪运行状况并平衡负载或故障转移。 Each Subscriber can keep track of what they are suppose to process. 每个订户都可以跟踪他们要处理的内容。 For example from the link you provided each subscriber knows the subject it is listening to and keep receiving hearbeat from other subscriber in case of heartbeat failure failover listener will start taking messages for failed listener. 例如,从您提供的链接中,每个订阅者都知道其正在侦听的主题,并在心跳失败的情况下继续接收来自其他订阅者的声音,故障转移监听器将开始为失败的监听器接收消息。 I think you can use JMS Message Selector to implement filters. 我认为您可以使用JMS消息选择器来实现过滤器。 A good reference to start with can be this old article on Javaworld. 可以从Javaworld上的这篇旧文章开始很好地参考。

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

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