虚拟主题/队列和持久性 [英] Virtual topics/queues and durability

查看:75
本文介绍了虚拟主题/队列和持久性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当没有消费者在听时,发布到虚拟主题的消息会发生什么?经纪人会保留他们一段时间,直到有订阅者可用吗?

What will happen to messages posted to a virtual topic when there are no consumers listening ? Will the broker hold them for a certain while until a subscriber is available ?

更具体地说:
在T0和T1消息M0和M1被发布。在T2,消费者C1连接,他会收到M0和M1吗?显然,在T3和T4发布的消息M2和M3将由C1接收,但是在T5接收到的新消费者C2将收到什么呢?所有消息,M2和M3,还是没有?

More specifically : At T0 and T1 messages M0 and M1 are posted. At T2, consumer C1 connects, will he receive M0 and M1 ? Obviously messages M2 and M3 posted at T3 and T4 will be received by C1, but what will a new Consumer, C2, that connects at T5 receice ? All messages, M2 and M3, or none ?

推荐答案

这取决于主题的性质:
如果主题是持久性的(有持久性消费者订阅该主题) ),代理将消息保留在主题中,直到所有持久消费者都使用了消息为止。
如果主题是非持久性的(没有持久性消费者),则该消息甚至不会发送到该主题,因为不会有持久性订阅。

It depends on the nature of the topic: if the topic is durable (has durable consumers subscribing to it), the broker will hold the messages in the topic until all the durable consumers consumes the messages. if the topic is non-durable (no durable consumers), the message will not even be sent to the topic, as there will be no durable subscription.

以您的示例为例,我认为您使用的是持久订阅/用户:
情况1:

For your example, I'll consider that you are using durable subscriptions / consumers: Case 1:


  • T-2 C1和C2永久订阅主题

  • T-1 C1和C2断开连接

  • T0:M0已发布

  • T1:M1已发布

  • T2:C1连接。 C1收到M0和M1

  • T3:M3已过帐。 C1收到M3

  • T4:M4已过帐。 C1接收M4

  • T5:C2连接, C2接收M0,M1,M2,M3,M4

  • T-2 C1 and C2 make durable subscription to the topic
  • T-1 C1 and C2 disconnect
  • T0: M0 is posted
  • T1: M1 is posted
  • T2: C1 connects. C1 receives M0 and M1
  • T3: M3 is posted. C1 receives M3
  • T4: M4 is posted. C1 receives M4
  • T5: C2 connects, C2 receives M0, M1, M2, M3, M4

那是因为他们持有持久订阅
使用持久主题/队列时需要非常小心:如果使用者不退订,则代理将保留消息直到消息存储。爆炸。您需要确保它不会发生(通过设置驱逐政策和/或在消息上放置一个生存时间)。
当然,上一个示例将根据消费者进行持久订阅的时间而有所不同。

That's because they are holding durable subscriptions You need to be very careful when using durable topics / queues: if the consumer doesn't unsubscribe, the broker will hold the messages until the message store explodes. You will need to make sure it doesn't happen (by setting eviction policies and / or putting a Time to Live on the messages). Of course the previous example will vary depending when the consumer does the durable subscription.

如果您使用的是非持久性主题:

If you are using non-durable topics:


  • T-2 C1和C2正常订阅该主题

  • T-1 C1和C2断开连接

  • T0:M0已发布

  • T1:M1已发布

  • T2:C1连接。 C1没有收到任何东西

  • T3:发布了M3。 C1收到M3

  • T4:M4已过帐。 C1收到M4

  • T5:C2连接, C2没有收到任何东西

  • T-2 C1 and C2 make normal subscription to the topic
  • T-1 C1 and C2 disconnect
  • T0: M0 is posted
  • T1: M1 is posted
  • T2: C1 connects. C1 does not receive anything
  • T3: M3 is posted. C1 receives M3
  • T4: M4 is posted. C1 receives M4
  • T5: C2 connects, C2 does not receive anything

这篇关于虚拟主题/队列和持久性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆