gpt4 book ai didi

java - JMS 中的重复持久订阅是什么

转载 作者:行者123 更新时间:2023-12-02 00:08:53 26 4
gpt4 key购买 nike

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

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

我错过了什么吗?

最佳答案

引自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.

为了使持久订阅在一个持久订阅上为多个订阅者工作,代理必须存储从主题创建(由第一个订阅者)开始的每条消息,直到其过期,即如果没有消息 TTL,则可能永远存储指定,因为在任何时间点,新订阅者都可以弹出并声明它“错过”的所有消息(即,自创建订阅以来的所有消息)。这是不可行的。

我可能没有捕获重点,但我不明白让多个同时订阅者共享一个订阅会比定义两个单独的订阅更实用吗?

关于java - JMS 中的重复持久订阅是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13280754/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com