0

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 ?

nfpyfzyf
  • 2,891
  • 6
  • 26
  • 30

1 Answers1

0

You have to define it first.

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

Carl Hörberg
  • 5,973
  • 5
  • 41
  • 47
  • I've updated source. I can see `testqueue` now by `rabbitmqctl list_queues`, but there's no message in `testqueue`. – nfpyfzyf May 10 '13 at 01:22
  • 1
    If you're not using the "direct" exchange you have to bind the exchange to the queue: ```queue.bind(exchange, routing_key)``` – Carl Hörberg May 16 '13 at 05:38