This is my code:
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);
});
});
});
});
I'm using node 0.10.2 and node-amqp 0.1.6,
I can see textexchange
by rabbitmqctl list_exchanges
, but there's no testqueue
by rabbitmqctl list_queues
, what's wrong ?
You have to define it first.
connection.queue('testqueue', { durable: true })