这是我的代码:
var amqp = require('amqp');
var connection = amqp.createConnection( { host: 'localhost' }, { defaultExchangeName: 'testexchange' });
connection.on('ready', function () {
console.log('Connected to rabbitmq');
var exchange = connection.exchange('testexchange', {confirm:true}, function(exch){
console.log('Created exchange: ' + exch.name);
var queue = connection.queue('testqueue', { durable: true }, function(q) {
exch.publish('testqueue', {a:1}, {}, function(error) {
console.log(error);
});
});
});
});
我正在使用节点0.10.2和node-amqp 0.1.6,
我可以textexchange
看到rabbitmqctl list_exchanges
,但testqueue
没有rabbitmqctl list_queues
,有什么不对?
答案 0 :(得分:0)
你必须先定义它。
connection.queue('testqueue', { durable: true })