持久侦听器/使用者的用例场景 [英] Use case scenario of durable listeners/consumers

查看:118
本文介绍了持久侦听器/使用者的用例场景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在为一个主题创建并发使用者,即多个侦听器。我将它们配置为耐用。

So I am creating concurrent consumers to a topic i.e. multiple listeners. I am configuring them to be durable.

@Bean
public DefaultMessageListenerContainer listenerContainers() {
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
    container.setConnectionFactory(connectionFactory());
    container.setDestinationName(COMMENT_QUEUE);
    container.setPubSubDomain(true);
    container.setSessionTransacted(true);
    container.setConcurrentConsumers(2);
    container.setSubscriptionDurable(true);
    container.setMessageListener(datafileSubscriber);
    container.start();
    return container;
} 

我认为持久消费者的用例场景是

I am thinking the use case scenario of durable consumer is

我有一个发布消息的过程,并且听众会收到消息。我在想是否有人停止了这个过程,我又重新开始了,我不会因为持久的消费者而丢失消息和处理。

I have a process which publishes message and the message is pickedup by listeners. I was thinking if someone stopped the process and I restarted it again, I wouldnt lose messages and their processing because f durable consumers.

这是对的吗?

我不会丢失消息,因为消息在KahaDB中,并且在重新启动进程后,它将重新发送尚未完全处理给侦听器的消息,因为它们是持久的。
这是正确的解释吗?

I will not lose messages because the messages are in KahaDB and after the process is restarted it will resend the messages which havent been completely processed to listeners because they are durable. Is this right explanation ?

推荐答案

这是正确的;默认情况下,主题订阅不是持久的;只有订阅者主动消费获取消息。新消费者只会在订阅时发布新消息。

That is correct; topic subscriptions are not durable by default; only subscribers actively consuming get messages. New consumers only get new messages published while subscribed.

持久消费者更像是一个队列;经纪人跟踪他们并保持消息,直到所有这些消费者都收到消息。

A durable consumer acts more like a queue; the broker keeps track of them and keeps messages around until all such consumers have received them.

订阅只有在建立时才变得持久。如果经纪人不知道,则不会保留消息。因此,在发布任何消息之前建立持久订阅非常重要。

The subscription only becomes durable when it is established. If the broker doesn't know about it, messages won't be retained. Hence it's important to establish your durable subscriptions before publishing any messages.

这篇关于持久侦听器/使用者的用例场景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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