JMS 持久性和持久性
JMS Durability and Persistence
我目前正在阅读有关 JMS
的文章,在阅读了几篇文章后,我对使用非持久消息的持久订阅有点困惑。让我们从:
http://www2.sys-con.com/itsg/virtualcd/java/archives/0604/chappell/index.html - 它说:
If a nonpersistent message is intended for a disconnected durable
subscriber, the message server saves the message to disk as though it
were a persistent message. In this case the difference between
persistent and nonpersistent messages is subtle, but very important.
For nonpersistent messages the JMS provider could fail before it's had
a chance to write the message out to disk on behalf of the
disconnected durable subscribers. Messages may be lost
还有一个来源:
http://openmessaging.blogspot.com/2009/04/durable-messages-and-persistent.html 说的完全不同:
If there are any durable subscriptions on this topic, then a copy of
the message is sent to those durable subscribers that are active. For
those durable subscriptions that are inactive, a copy of the message
is saved in memory and sent to them when they next become active.
This saved message will be lost if the broker is restarted. Since
non-persistent messages are not saved on disk, a broker restart means
that any inactive durable subscriptions that have not yet received the
message will miss out on the message.
那么,真相是什么:)?
一般而言:
1) 非持久消息不会保存到磁盘。因此,它们不为消息提供程序重启提供服务。
2) 另一方面,持久消息被保存到磁盘。因此,他们为消息传递提供程序重新启动提供服务。
大多数消息传递提供商都遵循上述概念。但是正如您所指出的,存在一些特定于实现的偏差。例如,IBM MQ 具有 "Semi Persistent" 消息(NPMCLASS
属性)的概念。尽管这些是 "Non Persistent" 条消息,但它们用于 MQ 消息传递提供程序的正常关闭和重启。如果MQ异常结束,则"Semi Persistent"条消息丢失。
所以它归结为实现细节。
希望对您有所帮助。
对于持久消息,代理会将消息保存到磁盘,但这取决于它有什么样的订阅者,如果没有持久订阅者,那么在某些实现中,消息一旦传递就会被删除。
我目前正在阅读有关 JMS
的文章,在阅读了几篇文章后,我对使用非持久消息的持久订阅有点困惑。让我们从:
http://www2.sys-con.com/itsg/virtualcd/java/archives/0604/chappell/index.html - 它说:
If a nonpersistent message is intended for a disconnected durable subscriber, the message server saves the message to disk as though it were a persistent message. In this case the difference between persistent and nonpersistent messages is subtle, but very important. For nonpersistent messages the JMS provider could fail before it's had a chance to write the message out to disk on behalf of the disconnected durable subscribers. Messages may be lost
还有一个来源: http://openmessaging.blogspot.com/2009/04/durable-messages-and-persistent.html 说的完全不同:
If there are any durable subscriptions on this topic, then a copy of the message is sent to those durable subscribers that are active. For those durable subscriptions that are inactive, a copy of the message is saved in memory and sent to them when they next become active.
This saved message will be lost if the broker is restarted. Since non-persistent messages are not saved on disk, a broker restart means that any inactive durable subscriptions that have not yet received the message will miss out on the message.
那么,真相是什么:)?
一般而言:
1) 非持久消息不会保存到磁盘。因此,它们不为消息提供程序重启提供服务。
2) 另一方面,持久消息被保存到磁盘。因此,他们为消息传递提供程序重新启动提供服务。
大多数消息传递提供商都遵循上述概念。但是正如您所指出的,存在一些特定于实现的偏差。例如,IBM MQ 具有 "Semi Persistent" 消息(NPMCLASS
属性)的概念。尽管这些是 "Non Persistent" 条消息,但它们用于 MQ 消息传递提供程序的正常关闭和重启。如果MQ异常结束,则"Semi Persistent"条消息丢失。
所以它归结为实现细节。
希望对您有所帮助。
对于持久消息,代理会将消息保存到磁盘,但这取决于它有什么样的订阅者,如果没有持久订阅者,那么在某些实现中,消息一旦传递就会被删除。