gpt4 book ai didi

RabbitMQ:由交换确认的消息,没有任何现有的绑定(bind)

转载 作者:行者123 更新时间:2023-12-03 23:47:05 24 4
gpt4 key购买 nike

我正在向没有任何绑定(bind)到任何队列的主题交换发送消息。只是一个空白的交换。
该 channel 被创建为确认 channel ,每次发送消息时都会调用我的确认回调。
奇怪的是,对于每条消息,我都会得到确认。

我做错了什么或误解了发布者确认的工作方式吗?
我如何知道消息是路由到队列还是被交换机丢弃?

我正在为节点使用 amqplib。

好吧,可能我没有足够清楚地解释我的问题。所以这里有一些代码:

var amqp = require('amqplib/callback_api');
amqp.connect('amqp://host' , function(err, conn) {

conn.createConfirmChannel(function(err, ch) {

channel.assertExchange('my_awsome_exchange', 'topic', {durable: true});

channel.publish('my_awsome_exchange', 'routing_key', new Buffer('some data'),
{
mandatory: true
},
function(err){
// err is null no matter if a queue is bound to the exchange or not
console.log(err);
});
});
});

如您所见,创建了一个交换,但还没有队列绑定(bind)到该交换。所以我的期望是永远不会确认向这个交易所发送消息。
@Teddy:我从文档中知道这一部分,这就是我如此困惑的原因。
由于消息未路由到任何队列,因此我预计消息会被取消。

最佳答案

这是设计使然。检查此link .它清楚地说:

When will messages be confirmed?

For unroutable messages, the broker will issue a confirm once the exchange verifies a message won't route to any queue (returns an empty list of queues). If the message is also published as mandatory, the basic.return is sent to the client before basic.ack. The same is true for negative acknowledgements (basic.nack).

For routable messages, the basic.ack is sent when a message has been accepted by all the queues. For persistent messages routed to durable queues, this means persisting to disk. For mirrored queues, this means that all mirrors have accepted the message.

关于RabbitMQ:由交换确认的消息,没有任何现有的绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35649764/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com