java JMS 中的 PointToPoint 与发布/订阅模型?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13377703/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PointToPoint vs Publish/subscribe model in JMS?
提问by M Sach
I am new to JMS.I have started with hello world where i am publishing the message from java application on Topic and listening it from client(node.js javascript).I have gone thru http://en.wikipedia.org/wiki/Java_Message_Service. Now i have got some doubts based on my previuos theortical understanding and what is suggested at above link?
我是 JMS 新手。我从 hello world 开始,在那里我从 Java 应用程序发布消息到 Topic 并从客户端(node.js javascript)收听它。我已经通过http://en.wikipedia.org/wiki /Java_Message_Service。现在我根据我以前的理论理解和上面链接的建议有一些疑问?
As per my understanding,Point to Point is the queue implementation where there can be at most one consumer subscribed on queue and can be consumed by that only. Neither producer nor the consumer knows about each other.Queue is hosted on message brokers in my case Apache active MQ. Queue can be created by producer before publishing the message(or it can be created from console in advance).
根据我的理解,点对点是队列实现,其中最多可以有一个消费者订阅队列,并且只能由该消费者使用。生产者和消费者都不知道对方。在我的情况下,队列托管在消息代理上,Apache 活动 MQ。队列可以在发布消息之前由生产者创建(或者可以提前从控制台创建)。
In case of Publish/subscribe Model, its almost same as PointToPoint except the fact we use Topic instead of queue.In this model, there can be more than more consumer on Topic. Once the message is published, all the subscribers will be notified. Now if any of the subscriber, send the acknowledgment for the published message, message will taken as consumed and it will no longer be available for new subscriber?
在发布/订阅模型的情况下,除了我们使用主题而不是队列之外,它几乎与 PointToPoint 相同。在这个模型中,主题上可以有更多的消费者。消息发布后,将通知所有订阅者。现在,如果任何订阅者发送对已发布消息的确认,消息将被视为已消费,新订阅者将不再可用?
回答by Shashi
Point to Point means message(s) is sent from one application(producer or sender) to another application(consumer/receiver) via a queue. There can be more than one consumer listening on a queue but only one of them will be get the message. Hence it is Point to Point or One to One.
点对点意味着消息通过队列从一个应用程序(生产者或发送者)发送到另一个应用程序(消费者/接收者)。可以有多个消费者在一个队列上监听,但只有一个消费者会收到消息。因此它是点对点或一对一。
On the other hand Publish/Subscribe is another messaging model where a message(or publication as it is commonly called) is sent to multiple consumers(or subscribers) through a topic. The topic is the link between publisher and subscriber. The subscribers may or may not acknowledge the published message. Implementations like JMS acknowledge the message the messaging providers but not the sender of the message. Publications will be received by all subscribers, durable and non-durable. Any new subscribers on the same topic will not get the publication unless it is a Retained publication.
另一方面,发布/订阅是另一种消息传递模型,其中通过主题将消息(或通常称为发布)发送给多个消费者(或订阅者)。主题是发布者和订阅者之间的链接。订阅者可能会或可能不会确认发布的消息。像 JMS 这样的实现会向消息传递提供者确认消息,但不会确认消息的发送者。出版物将被所有订阅者接收,持久的和非持久的。除非是 Retained 发布,否则同一主题的任何新订阅者都不会获得该发布。
I would recommend you to read further on,
我建议你进一步阅读,
- Durable subscription
- Non-durable subscription
- Retained publication
- 持久订阅
- 非持久订阅
- 保留出版物