0

I'm trying to achieve something very simple - connect to a RabbitMQ exchange and consume messages. I'm using https://github.com/postwait/node-amqp. Here's the NodeJS code.

var rabbitMQ = amqp.createConnection({
    host: 'localhost'
});

rabbitMQ.on('ready', function() {
    console.log('Connected to RabbitMQ');
    var exchange = rabbitMQ.exchange('foobar');

    // some more logic
});

However, when I run the server, the line console.log('Connected to RabbitMQ') gets executed repeatedly forever. Of course, this behavior disappears when I remove var exchange = connection.exchange('foobar').

I'm fairly new to NodeJS, and I've tried reading up the docs and Googling around for example code, but nothing works. What am I missing?

4

0 回答 0