質問

Does anyone have an example of creating a topic exchange in Node-amqp? I've already gone through https://github.com/rabbitmq/rabbitmq-tutorials/tree/master/javascript-nodejs but unfortunately it doesn't recreate tutorials 4+ from the RabbitMQ website.

役に立ちましたか?

解決

This might be an over simplistic answer but at a basic level it's doable like this...

var amqp = require('amqp');
var connection = amqp.createConnection({ host: '127.0.0.1' });
connection.on('ready', function () {
  var exchange = connection.exchange('my-super-xchange', {type: 'topic'});
  exchange.on('open', function(){
    console.log('Lets do this!');
  })
})

Once you have run the above, the exchange should now be visible on your rabbitMQ instance

$ rabbitmqctl list_exchanges
Listing exchanges ...
    direct
amq.direct  direct
amq.fanout  fanout
amq.headers headers
amq.match   headers
amq.rabbitmq.log    topic
amq.rabbitmq.trace  topic
amq.topic   topic
dingo   topic
my-super-xchange    topic
...done.
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top