简体   繁体   English

JMS消息的持久性

[英]JMS persistence of message

In the JMS publish / subscribe mode, two consumers subscribe same topic. 在JMS发布/订阅模式下,两个使用者订阅同一主题。 One consumer is running, but another one is down when producer send message out, it still save the message for the consumer which is not up running ? 一个使用者正在运行,但是另一个使用者在生产者发送消息时关闭了,它仍为未启动的使用者保存消息?

Thanks 谢谢

I believe you can if you use the combination of Persistent message delivery and Durable subscription to the topic. 我相信您可以将持久性消息传递和持久订阅这一主题结合使用。

From: http://docs.oracle.com/javaee/5/tutorial/doc/bncdx.html 来自: http : //docs.oracle.com/javaee/5/tutorial/doc/bncdx.html

Pub/sub messaging has the following characteristics. 发布/订阅消息传递具有以下特征。

Each message can have multiple consumers. 每个消息可以有多个使用者。

Publishers and subscribers have a timing dependency. 发布者和订阅者具有时间依赖性。 A client that subscribes to a topic can consume only messages published after the client has created a subscription, and the subscriber must continue to be active in order for it to consume messages. 订阅主题的客户端只能使用在客户端创建订阅后发布的消息,并且订阅者必须继续处于活动状态才能使用消息。

The JMS API relaxes this timing dependency to some extent by allowing subscribers to create durable subscriptions, which receive messages sent while the subscribers are not active. JMS API通过允许订阅者创建持久订阅(在订阅者不活动时接收发送的消息),在某种程度上放松了这种时序依赖性。 Durable subscriptions provide the flexibility and reliability of queues but still allow clients to send messages to many recipients. 持久订阅可提供队列的灵活性和可靠性,但仍允许客户端将消息发送给许多收件人。 For more information about durable subscriptions, see Creating Durable Subscriptions. 有关持久订阅的更多信息,请参阅创建持久订阅。

This is where we use javax.jms.Session.createDurableSubscriber : 这是我们使用javax.jms.Session.createDurableSubscriber

The JMS provider retains a record of this durable subscription and insures that all messages from the topic's publishers are retained until they are acknowledged by this durable subscriber or they have expired. JMS提供者保留该持久订阅的记录,并确保保留来自主题发布者的所有消息,直到该持久订阅者确认它们或它们已过期为止。

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

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