客户端使用 STOMP 版本 1.2 而不是 RabbitMQ 版本 3.9.3。
客户端用于聊天应用程序作为传入消息的订阅者。
a["CONNECTED\nserver:RabbitMQ/3.9.3\nsession:session-paGrRWWiEsYECaWdVdqkXQ\nheart-beat:4000,4000\nversion:1.2\nuser-name:6208370595c29c4357f9b81c\n\n\u0000"]
订阅的 ack
标头是client-individual
。
客户端能够从 RabbitMQ 中确认
消息而不会出现任何异常。
问题是,当客户端不确认
时,消息不会重新传递给客户端。
如果订阅者没有确认
消息,我希望将消息重新传递给订阅者。
是否可以使用 STOMP 和 RabbitMQ 内置解决方案创建这样的功能,而不进行任何自定义确认?
我尝试过的另一种更糟糕的解决方案是,我在rabbitmq.conf中将consumer_timeout设置为10000,这应该断开10秒内没有确认消息的订阅者,然后客户端将重新连接到客户端并获取丢失的消息。
该解决方案的问题在于,在未发送 ack 后断开订阅者需要 1 分钟,而不是 10 秒。
The client uses STOMP version 1.2 over RabbitMQ version 3.9.3.
The client is used for a chat app as a subscriber for incoming messages.
a["CONNECTED\nserver:RabbitMQ/3.9.3\nsession:session-paGrRWWiEsYECaWdVdqkXQ\nheart-beat:4000,4000\nversion:1.2\nuser-name:6208370595c29c4357f9b81c\n\n\u0000"]
The ack
header on subscription is client-individual
.
The client is able to acknowledge
a message without any exceptions from RabbitMQ.
The problem is, when the client doesn't acknowledge
, the message isn't redelivered to the client.
I want to have the message redelivered to the subscriber if the subscriber didn't acknowledged
the message.
Is it possible to create such a feature using STOMP and RabbitMQ built-in solutions, without doing any custom acknowledges?
The alternative worse solution I tried was that I set up consumer_timeout to 10000
in rabbitmq.conf
, which should disconnect a subscriber which doesn't ack a message for 10s, then the client would reconnect to the client and fetch the missed messaged.
The problem with this solution is that it takes 1 minute, not 10 seconds to disconnect a subscriber after not sending ack.
发布评论
评论(2)
nack 消息的处理方式由消息代理决定,在您的例子中是 RabbitMq。它们可以被丢弃、发送到死信队列或重新排队。
这些文档将为您提供帮助:https://www.rabbitmq.com/nack.html
为了使用重新排队机制,您必须在批量情况下使用
basic.reject
或basic.nack
。如何设置取决于您使用的客户端库 api。
另请参阅:https://www.rabbitmq.com/confirms.html#消费者 nacks 请求
How nack messages are handled is decided by the message broker, in your case RabbitMq. They can either be dropped, sent to a dead letter queue or re-enqueued.
The docs will help you out: https://www.rabbitmq.com/nack.html
In order to use requeuing mechanism you have to use
basic.reject
orbasic.nack
in case of bulk.How you set it depends on the client library api you use.
Also refer to: https://www.rabbitmq.com/confirms.html#consumer-nacks-requeue
嗯...关于使用rabbitmq 时选择哪种配置有很多讨论。我将推荐以下设置(首先)
使用
fanout
模型(如 文档)。这将允许您:简而言之:是的,有一个适合您需求的配置
深入:您应该仔细设计您的设置以满足您的所有需求(包括高可用性),以确保您的代码和部署能够随着项目的进展而保持不变
Well...there's lots to discuss about which configuration to choose when using
rabbitmq
. I will recommend the following setup (to begin with)Use
fanout
model (as described in the docs). This will allow you to:In short: yes, there is a configuration which suits your needs
In depth: you should carefully craft your setup to suit all your needs (including high availability) in order to ensure that your code and deployment will hold as your project progress