我是tring,rabbitmq-tutorials版本可以工作,但是node.js版本不能发送消息。我不知道哪里出了问题。
var amqp = require('amqp');
var amqp_hacks = require('./amqp-hacks');
var connection = amqp.createConnection({host: 'localhost'});
connection.on('ready', function(){
connection.publish('hello_node', 'Hello World!');
console.log(" [x] Sent 'Hello World!'");
amqp_hacks.safeEndConnection(connection);
});在我运行node send.js之后,运行进程node recv.js不能接收任何东西。并且rabbitmqctl list_queues不显示hello_node队列。
发布于 2013-04-23 03:27:36
您需要指示队列,然后发布。该版本应该可以工作:
var amqp = require('amqp');
var amqp_hacks = require('./amqp-hacks');
var connection = amqp.createConnection({host: 'localhost'});
connection.on('ready', function(){
connection.queue('hello_node', {'durable': false}, function(q){
connection.publish('hello_node', 'Hello World!');
console.log(" [x] Sent 'Hello World!' to 'hello_node'");
amqp_hacks.safeEndConnection(connection);
});
});https://stackoverflow.com/questions/16144665
复制相似问题