Plain consumer.
One plain consumers can listen to many plain producers.
Init example:
const iamqp = require('iamqp');
const amqpUri = 'amqp://localhost';
const channel = 'amqp-channel-b';
let plainConsumer = new iamqp.PlainConsumer(amqpUri, channel);
// This needs to be done or the errors will bubble up.
plainConsumer.getEventer().on('error', (err) => {
console.log('consumer error:' + err.message);
});
// For when the connection is established.
plainConsumer.getEventer().on('connected', () => {
console.log('consumer connected');
});
// Get messages.
plainConsumer.getEventer().on('message', (message) => {
console.log('consumer message:' + message);
});
// Open the connection - this takes some time and is not sync
plainConsumer.openConnection();
// ...
// Close the connection
if (plainConsumer.closeConnection()) {
console.log('consumer connection closing ...');
}
...