Given that you're asking about replacing shared DB with either ActiveMQ or remote method call, I'm assuming your use case is really message passing versus application shared state; shared DB is obviously a good way to do shared state between multiple applications. Your description also makes me think that your application is sending a notification or event to other applications because something interesting has happened...
Remote method calls work when your calling a single application, you need immediate response, and you know the other application will be available (i.e. running). Many systems find this approach challenging if the receiving application may not be running when the message needs to be sent. Remote methods calls are also challenging if you currently, or in the future, need to send to multiple applications, especially if future receivers are unknown to the sending application.
MOM, and ActiveMQ specifically, is a great approach to reliable and asynchronously sending messages to one or more receivers. The sending application gives ActiveMQ the message and then continues on doing its work (doesn't block your application for doing more work). The message receiver(s) will receive the message when they are connected to ActiveMQ - that is, if they are connected when the message is sent its effectively as fast as remote method; if the receiver connects at a later time, they will receive when they connect (no polling). ActiveMQ ensures the message is safe till the receiver acknowledges receipt.
If you are sending events, using a messaging system like ActiveMQ is really good in that you can use a paradigm called publish / subscribe where messages (events) can be delivered to multiple receivers. These receivers are unknown to the sending application; they just need to know how to connect to ActiveMQ. This paradigm is a great way to de-couple your applications; your application sends interesting events, and other applications that could benefit from knowing that event happened can connect to ActiveMQ in the future...
A great resource for many integration patterns, including publish / subscribe, is Gregor Hohpe's Enterprise Integration Patterns site. More information on ActiveMQ can be found at the Apache ActiveMQ or at FuseSource's ActiveMQ site
发布评论
评论(1)
鉴于您询问如何使用 ActiveMQ 或远程方法调用替换共享数据库,我假设您的用例实际上是消息传递与应用程序共享状态;共享数据库显然是在多个应用程序之间共享状态的好方法。您的描述还让我认为您的应用程序正在向其他应用程序发送通知或事件,因为发生了一些有趣的事情...
当您调用单个应用程序时,远程方法调用起作用,您需要立即响应,并且您知道其他应用程序将可用(即运行)。如果在需要发送消息时接收应用程序可能没有运行,许多系统发现这种方法具有挑战性。如果您当前或将来需要发送到多个应用程序,尤其是发送应用程序未知未来的接收者时,远程方法调用也具有挑战性。
MOM,特别是 ActiveMQ,是一种向一个或多个接收者可靠、异步发送消息的好方法。发送应用程序向 ActiveMQ 提供消息,然后继续执行其工作(不会阻止您的应用程序执行更多工作)。消息接收者在连接到 ActiveMQ 时将接收消息 - 也就是说,如果在消息发送时它们已连接,则其有效速度与远程方法一样快;如果接收者稍后连接,他们将在连接时接收(无轮询)。 ActiveMQ 确保消息安全,直到接收者确认收到。
如果您要发送事件,那么使用像 ActiveMQ 这样的消息传递系统确实很好,因为您可以使用称为发布/订阅的范例,其中消息(事件)可以传递到多个接收者。这些接收者对于发送应用程序来说是未知的;他们只需要知道如何连接到 ActiveMQ。这种范例是解耦应用程序的好方法;您的应用程序发送有趣的事件,而其他应用程序可以从知道事件发生中受益,可以在将来连接到 ActiveMQ...
Gregor Hohpe 的 企业集成模式 站点。有关 ActiveMQ 的更多信息,请访问 Apache ActiveMQ 或 FuseSource 的 ActiveMQ 站点
希望有所帮助,
斯科特
Given that you're asking about replacing shared DB with either ActiveMQ or remote method call, I'm assuming your use case is really message passing versus application shared state; shared DB is obviously a good way to do shared state between multiple applications. Your description also makes me think that your application is sending a notification or event to other applications because something interesting has happened...
Remote method calls work when your calling a single application, you need immediate response, and you know the other application will be available (i.e. running). Many systems find this approach challenging if the receiving application may not be running when the message needs to be sent. Remote methods calls are also challenging if you currently, or in the future, need to send to multiple applications, especially if future receivers are unknown to the sending application.
MOM, and ActiveMQ specifically, is a great approach to reliable and asynchronously sending messages to one or more receivers. The sending application gives ActiveMQ the message and then continues on doing its work (doesn't block your application for doing more work). The message receiver(s) will receive the message when they are connected to ActiveMQ - that is, if they are connected when the message is sent its effectively as fast as remote method; if the receiver connects at a later time, they will receive when they connect (no polling). ActiveMQ ensures the message is safe till the receiver acknowledges receipt.
If you are sending events, using a messaging system like ActiveMQ is really good in that you can use a paradigm called publish / subscribe where messages (events) can be delivered to multiple receivers. These receivers are unknown to the sending application; they just need to know how to connect to ActiveMQ. This paradigm is a great way to de-couple your applications; your application sends interesting events, and other applications that could benefit from knowing that event happened can connect to ActiveMQ in the future...
A great resource for many integration patterns, including publish / subscribe, is Gregor Hohpe's Enterprise Integration Patterns site. More information on ActiveMQ can be found at the Apache ActiveMQ or at FuseSource's ActiveMQ site
Hope that helps,
Scott