Build Status

FeathersJS AMQP events

Publish service events with using AMQP protocol. Supports reconnect on lost connection.

Usage

const feathers = require('@feathersjs/feathers');
const express = require('@feathersjs/express');
const services = require('./services');
const amqpEvents = require('feathers-amqp-events');
const app = express(feathers());

app.use(express.json())
  .use(express.urlencoded({ extended: true }))
  .configure(express.rest())
  .configure(services())
  .configure(amqpEvents({
    amqp: {
      url: 'amqp://localhost', // url to your RabbitMQ connection
      exchange: 'my-app'       // all events will be published to this exchange
      retryOptions: { max_tries: 100, interval: 500 } // bluebird-retry options for reconnect
    },
    original: true ,            // publish object before update or not
    // the following are optional. No need to set them if you want to publish all of your services to RabbitMQ
    services: ['allow-this-service'],  // optional. To only allow specific services to be published to RabbitMQ
    ignoreServices: ['ignore-this-service']  // optional. To stop specific services from being published to RabbitMQ
  }));

module.exports = app;

Events

Routing key for every event will looks like <path>.<event>. For example:

  • posts.created
  • posts.updated
  • posts.removed
  • posts/:id/comments.created
  • posts/:id/comments.updated
  • posts/:id/comments.removed

Content

Message content will have following fields:

  • data - created, removed or updated object.
  • original - object before update.