Code Monkey home page Code Monkey logo

rabbot's Introduction

rabbot

Build Status Coverage Status Version npm npm Downloads Dependencies

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:

  • Attempt to gracefully handle lost connections and channels
  • Automatically re-assert all topology on re-connection
  • Support the majority of RabbitMQ's extensions
  • Handle batching of acknowledgements and rejections
  • Topology & configuration via JSON (thanks to @JohnDMathis!)
  • Built-in support for JSON, binary and text message bodies
  • Support for custom serialization

Assumptions & Defaults:

  • Fault-tolerance/resilience over throughput
  • Prefer "at least once delivery"
  • Default to publish confirmation
  • Default to ack mode on consumers
  • Heterogenous services that include statically typed languages
  • JSON as the default serialization provider for object based message bodies

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

  • improve support RabbitMQ backpressure mechanisms
  • add support for Rabbit's HTTP API

rabbot's People

Contributors

arobson avatar mkozjak avatar joseph-onsip avatar matmar10 avatar rg1220 avatar chavee avatar aankur avatar ifandelse avatar luddd3 avatar openam avatar leankitscott avatar dcneiner avatar swarthy avatar alonisser avatar brandonpsmith avatar chrisgundersen avatar cyri-l avatar codepope avatar esatterwhite avatar marcbachmann avatar secretfader avatar dvideby0 avatar rniemeyer avatar asleepysamurai avatar ryanwilliamquinn avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.