0

我很难理解持久订阅。我知道,当侦听器将自己注册为主题的持久订阅者时,它会告诉 JMS -“嘿,我是持久订阅者,从现在开始,如果我不在那里,您需要将所有消息存储在主题中并将这些消息传递给我当我回来时”

现在,如果是这样,为什么两个订阅者不能请求这个持久订阅?

我错过了什么吗?

4

2 回答 2

3

Quoting from the Java EE tutorial

A durable subscriber registers a durable subscription by specifying a unique identity that is retained by the JMS provider. Subsequent subscriber objects that have the same identity resume the subscription in the state in which it was left by the preceding subscriber. If a durable subscription has no active subscriber, the JMS provider retains the subscription’s messages until they are received by the subscription or until they expire.

To make durable subscriptions work for multiple subscribers on 1 durable subscription the broker would have to store each individual message from the creation of the topic (by the first-ever subscriber) until its expiry, ie potentially forever if no message TTL is specified, because at any point in time a new subscriber can pop in and claim all the messages it "missed" (that is, all messages since the subscription was created). That's just not feasible.

I may be missing the point here, but I can't see how having multiple simultaneous subscribers sharing a subscription would be more practical than defining two separate subscriptions?

于 2012-11-08T01:00:00.177 回答
0

对 Duplicate Durable Subscription 的理解是不正确的。

持久订阅并不意味着没有多个订阅者可以订阅。这意味着没有一个订阅者可以有两个不同的持久标识符。

于 2013-07-02T18:42:32.170 回答