Notwithstanding Previous Misdemeanors

    rmq-proxy

    1.0.0 • Public • Published

    rmq-proxy

    Send HTTP requests through a RabbitMQ exchange/queue to one or more HTTP servers as a proxy to enable controlled request consumption

    Usage

      // on the app that is receiving messages
      const connection = createRabbitMQConnection();
      const { receiver } = require('rmq-proxy');
      const closeReceiver = receiver({ connection, domains: ['my.domain.com'] });
    
    
    
      // on app that is sending messages to the receiver application
      const connection = createRabbitMQConnection();
      const { sender } = require('rmq-proxy');
      const { adapter } = await sender({ connection });
      const axios = require('axios');
    
      const response = await axios.get({ url: 'https://my.domain.com/something', adapter });
      // request used the RMQ exchange and queues instead of HTTP
    
    
    

    Methods

    sender

    Returns an object with two properties adapter and shutdown.

    • appId = The identifier of the app, default: random uuid
    • connection = Instance of amqplib.connect, optional
    • connectionOptions = Optional way to specify amqplib.connect options
    • exchange = The name of the exchange that is used to route messages to the domain queues created by the receiver method, defaults to 'http.proxy'.
    • exchangeOptions = The options used to assert the exchange into existence, see available options, defaults to { durable: true }.
    • queueOptions = The options used to assert the replyTo queue into existence, see available options, defaults to { autoDelete: true, exclusive: false, durable: false, arguments: { 'x-queue-mode': 'lazy' } }.
    • replyTo = The name used to create a queue capable of receiving the response message after the receiver has processed the request, defaults to random uuid.
    • simultaneous = The number of simultaneous messages to process from the replyTo queue, defaults to 2.

    receiver

    Returns a function that shutsdown the rmq connection

    • appId = The identifier of the app, default: random uuid
    • connection = Instance of amqplib.connect, optional
    • connectionOptions = Optional way to specify amqplib.connect options
    • exchange = The name of the exchange that is used to route messages to the domain queues created by the receiver method, defaults to 'http.proxy'.
    • exchangeOptions = The options used to assert the exchange into existence, see available options, defaults to { durable: true }.
    • queueOptions = The options used to assert the replyTo queue into existence, see available options, defaults to { autoDelete: true, exclusive: false, durable: false, arguments: { 'x-queue-mode': 'lazy' } }.
    • domains = An array of domains or an object with domains as keys and queue options as the field values, defaults to {}
    • limit = An async function that can delay execution of newly received request messages allowing limiting of execution, defaults to async () => {}

    Keywords

    none

    Install

    npm i rmq-proxy

    DownloadsWeekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    18.4 kB

    Total Files

    11

    Last publish

    Collaborators

    • samshull