0

这是我的代码:

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 和节点 amqp 0.1.6,

我可以看到textexchangerabbitmqctl list_exchanges但是没有testqueuerabbitmqctl list_queues怎么了?

4

1 回答 1

0

你必须先定义它。

connection.queue('testqueue', { durable: true })

于 2013-05-09T14:40:57.950 回答