简体   繁体   English

JMS持久性和持久性

[英]JMS Durability and Persistence

I am currently reading about JMS and after a few articles, there is a little bit of confusion about durable subscription with non-persistent messages in my head. 我目前正在阅读有关JMS文章,在一些文章之后,我对头部持久订阅非持久性消息存在一些困惑。 Let's start with: http://www2.sys-con.com/itsg/virtualcd/java/archives/0604/chappell/index.html - It says: 让我们从: 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. 对于非持久性消息,JMS提供程序可能会失败,然后才有机会代表断开连接的持久订阅者将消息写入磁盘。 Messages may be lost 消息可能会丢失

And another source: http://openmessaging.blogspot.com/2009/04/durable-messages-and-persistent.html says something totally different: 另一个来源: 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. 由于非持久性消息未保存在磁盘上 ,因此代理重新启动意味着任何尚未收到消息的非活动持久订阅将错过该消息。

So, what is the truth :)? 那么,真相是什么:)?

Generally speaking: 一般来说:

1) Non-persistent messages are not saved to disk. 1)非持久性消息不会保存到磁盘。 Hence they don't servive messaging provider restart. 因此,他们不会重新启动消息传递提供程序。

2) On the other hand persistent messages are saved to disk. 2)另一方面,持久性消息被保存到磁盘。 Hence they servive messaging provider restart. 因此,他们服务于消息传递提供程

Most messaging providers follow above concept. 大多数消息提供商遵循上述概念 But as you pointed out there are some implementation specific deviations. 但正如您所指出的,存在一些特定于实现的偏差。 For example IBM MQ has a concept of "Semi Persistent" message ( NPMCLASS attribute). 例如,IBM MQ具有“半持久”消息( NPMCLASS属性)的概念。 Although these are "Non Persistent" messages, they servive normal shutdown and restart of MQ messaging provider. 虽然这些是“非持久性”消息,但它们可以正常关闭并重新启动MQ消息传递提供程序。 If MQ ends abnormally, then "Semi Persistent" messages are lost. 如果MQ异常结束,则“半持久”消息将丢失。

So it boils down to implementation specifics. 所以它归结为实现细节。

Hope this helped. 希望这有帮助。

With the Persistent messages, broker will save messages to disk, but depends on what kind of subscribers it has, if no durable subscribers then with some implementations messages are deleted once delivered. 使用Persistent消息,代理将消息保存到磁盘,但取决于它具有哪种订阅者,如果没有持久订阅者,那么一些实现消息一旦被传递就被删除。

在此输入图像描述

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

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