arobson / rabbot

Deprecated: Please see https://github.com/Foo-Foo-MQ/foo-foo-mq
MIT License
277 stars 129 forks source link

rabbot

Build Status Coverage Status Version npm npm Downloads Dependencies

Deprecated

As many have already noticed, I have not had the time to maintain this library in quite some time. I appreciate that Zach Lintz has taken the initiative to fork this and continue maintenance over at [https://github.com/foo-foo-mq/foo-foo-mq]. I appreciate that Zach has made it possible for folks to continue using this approach. Thanks, Zach! :tada:

Summary

This is a very opinionated abstraction over amqplib to help simplify the implementation of several messaging patterns on RabbitMQ.

!Important! - successful use of this library will require a conceptual knowledge of AMQP and an understanding of RabbitMQ.

Features:

Assumptions & Defaults:

Documentation You Should Read

Other Documents

Demos

API Example

This contrived example is here to make it easy to see what the API looks like now that documentation is broken up across multiple pages.

const rabbit = require('rabbot');

rabbot.handle('MyMessage', (msg) => {
  console.log('received msg', msg.body);
  msg.ack();
});

rabbot.handle('MyRequest', (req) => {
  req.reply('yes?');
});

rabbot.configure({
  connection: {
    name: 'default',
    user: 'guest',
    pass: 'guest',
    host: 'my-rabbot-server',
    port: 5672,
    vhost: '%2f',
    replyQueue: 'customReplyQueue'
  },
  exchanges: [
    { name: 'ex.1', type: 'fanout', autoDelete: true }
  ],
  queues: [
    { name: 'q.1', autoDelete: true, subscribe: true },
  ],
  bindings: [
    { exchange: 'ex.1', target: 'q.1', keys: [] }
  ]
}).then(
  () => console.log('connected!');
);

rabbot.request('ex.1', { type: 'MyRequest' })
  .then(
    reply => {
      console.log('got response:', reply.body);
      reply.ack();
    }
  );

rabbot.publish('ex.1', { type: 'MyMessage', body: 'hello!' });

setTimeout(() => {
  rabbot.shutdown(true)
},5000);

Roadmap