RabbitMQ/AMQP 未处理的通道错误 - NOT_FOUND
我正在尝试从 Ruby 脚本(使用 Bunny)向 RabbitMQ 发布消息,并从Node.js 服务器(使用 node-amqp)。
第一条消息成功到达,但随后在 Node.js 中记录了一个错误,并且连接关闭,并且没有收到进一步的消息:
mu:charlie-node tom$ node charlie.js
22 Jul 09:11:04 - Running in development environment.
22 Jul 09:11:04 - Connected to AMQP.
22 Jul 09:11:04 - {"build_id":1234}
Unhandled channel error: NOT_FOUND - unknown delivery tag 1
如果我将两条消息发布到交换中,然后运行 Node.js 服务器,我可以看到两条消息其中一些在记录错误之前到达,这表明 RabbitMQ 在交换或队列为空时正在关闭它。但是,由于我已将这两个文件的 autoDelete 设置为 false,所以不应该这样做。
有什么建议吗?
我的 node.js 脚本看起来像这样:
var amqpConnection = amqp.createConnection({ host: config.rabbitmq.host });
amqpConnection.addListener('ready', function() {
sys.log("Connected to AMQP.");
var exchange = amqpConnection.exchange('job_exchange', {
type : 'topic',
passive : false,
durable : true,
autoDelete : false
})
exchange.addListener('open', function() {
var queue = amqpConnection.queue('arthr_queue', {
passive : false,
autoDelete : false,
durable : true,
exclusive : false
});
queue.bind(exchange, '#');
queue.subscribe(function(message) {
sys.log(message.data.toString());
});
});
});
我的 Ruby 脚本看起来像这样:
require 'rubygems'
require 'bunny'
require 'json'
b = Bunny.new(:logging => true)
b.start
job_exchange = b.exchange('job_exchange',
:type => :topic,
:durable => true,
:auto_delete => false,
:passive => false
)
message = {
:build_id => 1234
}
job_exchange.publish(message.to_json, :key => 'arthr.rebuild')
b.stop
I'm trying to publish messages to RabbitMQ, from a Ruby script (using Bunny) and consume them from a node.js server (using node-amqp).
The first message arrives successfully, but then an error is logged inside node.js, and the connection closes, and no further messages are received:
mu:charlie-node tom$ node charlie.js
22 Jul 09:11:04 - Running in development environment.
22 Jul 09:11:04 - Connected to AMQP.
22 Jul 09:11:04 - {"build_id":1234}
Unhandled channel error: NOT_FOUND - unknown delivery tag 1
If I publish two messages into the exchange, and then run the node.js server I can see both of them arrive before the error is logged, which suggests to me that RabbitMQ is closing the exchange or queue when it's empty. However, since I've got autoDelete set to false on both of those it shouldn't.
Any suggestions?
My node.js script looks something like this:
var amqpConnection = amqp.createConnection({ host: config.rabbitmq.host });
amqpConnection.addListener('ready', function() {
sys.log("Connected to AMQP.");
var exchange = amqpConnection.exchange('job_exchange', {
type : 'topic',
passive : false,
durable : true,
autoDelete : false
})
exchange.addListener('open', function() {
var queue = amqpConnection.queue('arthr_queue', {
passive : false,
autoDelete : false,
durable : true,
exclusive : false
});
queue.bind(exchange, '#');
queue.subscribe(function(message) {
sys.log(message.data.toString());
});
});
});
And my Ruby script looks like:
require 'rubygems'
require 'bunny'
require 'json'
b = Bunny.new(:logging => true)
b.start
job_exchange = b.exchange('job_exchange',
:type => :topic,
:durable => true,
:auto_delete => false,
:passive => false
)
message = {
:build_id => 1234
}
job_exchange.publish(message.to_json, :key => 'arthr.rebuild')
b.stop
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这是 node-amqp 中的一个错误。当 options.ack 设置为 false 时,代码默认发送 ack。
amqp 0.8 规范规定,当 noAck 时,服务器代表客户端执行此操作。
我亲眼目睹了 RabbitMQ 1.8.1 的错误。也许他们变得更严格了。
它已在我的分支中修复(http://github.com/spahl/node-amqp )并且所有测试都通过。
我还修复了它尝试将默认的“amq.topic”交换重新声明为非持久交换的事实。
I think this is a bug in node-amqp. The code sends an ack by default when options.ack is set to false.
The amqp 0.8 specifications say that the server does it on the clients behalf when noAck.
I witnessed the bug with RabbitMQ 1.8.1. Maybe they got stricter.
It is fixed in my branch (http://github.com/spahl/node-amqp) and all the tests pass.
I also fixed the fact that it tries to redeclare the default 'amq.topic' exchange as non durable.