java 带有 HornetQ 的 JBoss 7 中 JMS 队列的“持久”属性是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13816718/
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
What is the meaning of 'durable' attribute for JMS Queue in JBoss 7 with HornetQ?
提问by acalypso
During configuration of JMS queues on JBoss 7 with HornetQ (based on standalone-full.xml configuration) I noticed an attribute 'durable'.
在使用 HornetQ(基于 standalone-full.xml 配置)在 JBoss 7 上配置 JMS 队列期间,我注意到一个属性“durable”。
I browsed several sources and many of them stated queues are always 'durable', meaning the message will be always delivered, even in case of potential receivers being inactive at the time of send.
我浏览了几个来源,其中许多都说队列总是“持久的”,这意味着即使在发送时潜在的接收者处于非活动状态,消息也将始终被传递。
Does this attribute in JBoss 7 HornetQ refer to temporary queues? Or does this attribute refer to some kind of non-temporary non-durable queues?
JBoss 7 HornetQ 中的这个属性是指临时队列吗?或者这个属性是指某种非临时非持久队列吗?
采纳答案by acalypso
After brief investigation I came up with a few conclusions. All observations are based on JBoss 7.1.1.Final with HornetQ Server 2.2.13.Final.
经过简短的调查,我得出了一些结论。所有观察均基于 JBoss 7.1.1.Final 和 HornetQ Server 2.2.13.Final。
The non-durable queue is not a temporary queue. It exists until it's manually deleted.
All the messages submitted to non-durable queue vanish upon JMS provider restart/failure (delivery modes, i.e. PERSISTENT / NON_PERSISTENT of the submitted messages are ignored).
The value of JMSDeliveryMode header element of the messages is not modified. In particular, if the message was submitted with PERSISTENT delivery mode to a non-durable queue, the flag is set to PERSISTENT, even though the non-durable queue does not persist the message (it is lost in case of JMS provider restart/failure).
非持久队列不是临时队列。它一直存在,直到被手动删除。
所有提交到非持久队列的消息在 JMS 提供者重启/失败时消失(传递模式,即提交的消息的 PERSISTENT / NON_PERSISTENT 被忽略)。
消息的 JMSDeliveryMode 头元素的值没有被修改。特别是,如果消息以 PERSISTENT 交付模式提交到非持久队列,则该标志设置为 PERSISTENT,即使非持久队列不持久化消息(在 JMS 提供程序重启/失败的情况下它会丢失) )。
From the client side it seems to be a bit of a disturbing prospect, since the sender has potentially no way of knowing whether the declared delivery mode of the message will not be respected, due to the problematic meaning of 'non-durable' queue.
从客户端来看,这似乎是一个令人不安的前景,因为由于“非持久”队列的有问题的含义,发件人可能无法知道是否会不遵守声明的消息传递模式。
Furthermore, the term 'durable queue' in this context seems disjointed from the 'durable subscription', as it does not appear to affect delivery of messages to inactive consumers in any way.
此外,在这种情况下,术语“持久队列”似乎与“持久订阅”脱节,因为它似乎不会以任何方式影响向非活动消费者传递消息。
回答by Shashi
I feel the word "Durable" is more applicable to Topics than queues. A durable subscription is one where the publications for a subscriber are stored by the messaging provider when that subscriber is not running. Once the subscriber becomes active, these stored messages will be delivered to that subscriber. For non-Durable subscribers will not receive any publications if they are not active.
我觉得“持久”这个词比队列更适用于主题。持久订阅是一种订阅者的发布在订阅者未运行时由消息传递提供者存储的订阅。一旦订阅者变为活动状态,这些存储的消息将传递给该订阅者。对于非持久订阅者,如果他们不活跃,他们将不会收到任何出版物。
With respect to Queues, the messages are held in the queue till someone receives them or they expire. The messages can be persistent meaning they will survive restart of messaging provider and non-persistent where the messages are lost when messaging provider goes down.
对于队列,消息将保留在队列中,直到有人收到它们或它们过期。消息可以是持久的,这意味着它们将在消息提供程序重新启动时存活下来,并且在消息提供程序关闭时消息丢失的情况下是非持久的。
回答by AlexR
Durable subscription in JMS means that if subscriber disconnected and then connected again to JMS destination (queue or topic) it will receive all messages that have been sent to the destination so far and have not been expired yet.
JMS 中的持久订阅意味着如果订阅者断开连接然后再次连接到 JMS 目的地(队列或主题),它将收到到目前为止已发送到目的地且尚未过期的所有消息。