简体   繁体   English

我应该考虑在我的情况下使用JMS吗?

[英]Should I consider to use JMS in my case?

I'm not very familiar with JMS so, I can't understand whether I should consider it to use in my case. 我对JMS不太熟悉,所以我不明白是否应该考虑在我的情况下使用它。

I have 3 servers (running on tomcat) which are going to send some notifications to another server (call it PrincipalServer ) when some event occured on them. 我有3台服务器(在tomcat上运行),它们将在发生某些事件时将一些通知发送到另一台服务器(称为PrincipalServer )。 The PrincipalServer is running on tomcat too. PrincipalServer也在tomcat上运行。 When the notifications from one of those 3 servers reach the PrincipalServer it need to handle it in some way, depending on the message (For instance, persist some data in a database). 当这3个服务器之一的通知到达PrincipalServer它需要以某种方式处理它,具体取决于消息(例如,将某些数据持久存储在数据库中)。 Approximately, the rate of the notification would be 500k-1M a day. 通知的速率大约为每天500k-1M。

So, should I consider some JMS implementation like ActiveMQ ? 所以,我应该考虑像ActiveMQ这样的JMS实现吗?

It depends on a number of factors, but it may provide a benefit in your case. 它取决于许多因素,但可能会为您带来好处。 The main benefit provided by JMS is the ability to reliably queue work that can be done later. JMS提供的主要好处是能够可靠地对以后可以完成的工作进行排队。 There are three key reasons in my mind for using JMS over a web service, rest or ejb call. 我认为通过Web服务,Rest或ejb调用使用JMS的三个主要原因。 These are: 这些是:

  1. The client should return prior to this work being processed. 客户应在处理此工作之前返回。 If this work has to be done before returning to the client then don't use JMS, trying to build a synchronous invoke model over JMS while possible is choosing a hammer when you have a screw. 如果必须在返回客户端之前完成此工作,则不要使用JMS,而是尝试在JMS上构建同步调用模型,而可能的话,是在有螺丝的情况下选择锤子。
  2. The clients may process bursts of work that the back end can't keep up with. 客户可能会处理后端无法跟上的突发工作。 In this case JMS will store the messages until the back end can process the work. 在这种情况下,JMS将存储消息,直到后端可以处理工作为止。 Note that you still need to average the number of messages on the Queue to be zero, you can't add messages forever. 请注意,您仍然需要平均队列上的消息数为零,不能永远添加消息。
  3. The back end may go down independently of the front end. 后端可能会独立于前端而下降。 In this case the JMS provider will store the messages until the backend comes back up to process the work. 在这种情况下,JMS提供程序将存储消息,直到后端返回以处理工作为止。

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

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