RabbitMQ 主题交换队列上的消息

发布于 2024-12-15 16:24:49 字数 360 浏览 4 评论 0原文

注意:使用 RabbitMQ .NET 库

我的 RabbitMQ 上有一个名为 FXTO.HK 的主题交换和 FXTO.# 的绑定密钥 服务器将消息发布到该队列。

在客户端,队列具有唯一且随机的名称,但使用相同的绑定键 FXTO.#

我们使用客户端库中的 Subscription 类,该类工作正常:即。所有客户端同时收到该消息。

但是,在 RabbitMQ 管理 UI 中,服务器队列 (FXTO.HK) 显示队列中包含所有消息(它们不会从队列中删除)。

我的设置有什么问题吗?这些消息什么时候会从服务器队列中删除?

Note: Using RabbitMQ .NET library

I have a Topic Exchange on my RabbitMQ called FXTO.HK and a binding key of FXTO.#
The server publishes messages to this queue.

On the client side, the queues have a unique and random name but use the same binding key of FXTO.#

We use the Subscription class from the library on the client side which works fine: ie. the message is received by all clients at the same time.

However, in RabbitMQ management UI, the server queue (FXTO.HK) is showing to have all the messages in the queue (they are not removed from the queue).

Am I doing anything wrong in my setup? When will these messages be removed from the server queue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

玉环 2024-12-22 16:24:49

这个问题更适合 RabbitMQ Discuss 邮件列表。

但是,在 RabbitMQ 管理 UI 中,服务器队列 (FXTO.HK) 显示队列中包含所有消息(它们不会从队列中删除)。

这强烈表明您在使用消息后没有确认消息。看看 这个 例如,我发现您需要调用 Subscription.Ack 在每个之后调用 Subscription.Next (或在 NoAck 模式)

This question is better suited to the RabbitMQ Discuss mailing list.

However, in RabbitMQ management UI, the server queue (FXTO.HK) is showing to have all the messages in the queue (they are not removed from the queue).

This strongly suggests you're not ack'ing messages after consuming them. Looking at this example, I see you need to call Subscription.Ack after each call to Subscription.Next (or start the Subscription in NoAck mode)

你丑哭了我 2024-12-22 16:24:49

我不太清楚你的问题中的“客户端”和“服务器”是什么意思。 RabbitMQ 不理解客户端和服务器,只是将自己视为每个人的服务器。发布者和消费者本质上都不是客户端或服务器。

你说“我的 RabbitMQ 上有一个名为 FXTO.HK 的主题交换,并且绑定密钥为 FXTO。# 服务器将消息发布到此队列。”,但这没有意义。消息是否发布到 FXTO.HK 交换 或其他一些队列?我认为混乱可能是您问题的根源:

  • 如果您的带有 FXTO.?? 路由密钥的消息被发布到交换(即您有“交换”在 publish 函数的参数中设置),并使用 FXTO.# 绑定键绑定一个或多个队列,这些消息将被复制到每个绑定队列中。这些消息将保留在每个队列中,直到它们在无确认模式下被消耗或被确认。如果您碰巧有一个与绑定到交换器的交换器同名的队列(例如,交换器FXTO.HK通过一些绑定密钥绑定到队列FXTO.HK) ,不会因为它们共享相同的名称而发生特殊行为。消息将被复制到每个匹配的绑定队列(包括 FXTO.HK)中,并将保留在该队列中,直到消费者连接到它并确认它们。
  • 如果您的消息正在发布到队列(即您没有在发布参数中设置“交换”,或者您正在使用默认交换),则称为< code>FXTO.HK,您的消息将保留在该队列中,直到消费者连接到该队列并接收/确认它们。不会发生交换/扇出路由。

I'm not quite sure what "client" and "server" mean in your question. RabbitMQ doesn't understand clients and servers other than considering itself a server for everyone. Neither publishers nor consumers are inherently clients or servers.

You say "I have a Topic Exchange on my RabbitMQ called FXTO.HK and a binding key of FXTO.# The server publishes messages to this queue.", but that doesn't make sense. Are messages being published to the FXTO.HK exchange or some other queue? I think that confusion may be at the root of your issue:

  • If your messages with FXTO.?? routing keys are being published to an exchange (i.e. you have "exchange" set in the parameters to the publish function) with one or more queues bound to it with the binding key of FXTO.#, those messages will be duplicated into each bound queue. Those messages will remain in each queue until they are consumed in no-ack mode or acknowledged. If you happen to have a queue with the same name as the exchange bound to the exchange (e.g exchange FXTO.HK is bound to queue FXTO.HK with some binding key), no special behavior will occur as a result of their sharing the same name. Messages will be duplicated into each matching bound queue including FXTO.HK, and will sit in that queue until a consumer connects to it and acknowledges them.
  • If your messages are being published to a queue (i.e. you don't have "exchange" set in the parameters to publish or you're using the default exchange) called FXTO.HK, your messages will remain in that queue until a consumer connects to that queue and receives them/acknowledges them. No exchange/fanout routing will occur.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文