mateodelnorte / servicebus

Simple service bus for sending events between processes using amqp.
MIT License
420 stars 66 forks source link

Example using `send` callback. #73

Closed eddieajau closed 8 years ago

eddieajau commented 8 years ago

Hi Matt. Do you have any documentation on how to use the RabbitMQBus.send with the callback? Looking at the code, it seems coupled to the confirmChannel option and I'm not quite getting how that all works.

The use-case I'm looking at is a serial event chain where want to make sure that after processing one event, I've successfully sent it to the next queue before ack-ing.

Thanks in advance.

mateodelnorte commented 8 years ago

Yup. The option is enableConfirms. Would be happy to have a README.md PR for it.

Here's an example:

var config     = require('cconfig')();
var servicebus = require('servicebus');

var bus = servicebus.bus({
  enableConfirms: true,
  prefetch: config.SERVICEBUS_PREFETCH,
  url: config.RABBITMQ_URL
});

module.exports = bus;
mateodelnorte commented 8 years ago

Note, enableConfirms enables the following functionality on RabbitMQ: https://www.rabbitmq.com/confirms.html. Without it, it's not possible to know when your message has been sent successfully.