/AmqpRouter

A simple route system made with Node to use with Amqp protocol.

Primary LanguageJavaScript

AmqpRouter

A simple route system made with Node to use with Amqp protocol.

How to use ?

const { AmqpRouter } = require("AmqpRouter");

Routes with callback functions

AmqpRouter.add("your.route", (message, channel) => {
  // your handler here
});

Routes with named controllers

AmqpRouter.add("your.route", "YourController.yourAction");

On your controller, you have access to the message and channel object. Example:

"use strict";

class YourController {
  async yourAction({ message, channel }) {
    // your handler here
  }
}

module.exports = YourController;

In your AMQP (RabbitMQ) Server, enter the following code:

AmqpRouter.resolve(msg, channel);