1.0.5 • Published 6 years ago

aob-rabbit-wrapper v1.0.5

Weekly downloads
6
License
ISC
Repository
-
Last release
6 years ago

Usage

$ import { createRabbitConnectionToPublish } from 'aob-rabbit-wrapper'
$ import { createRabbitConnectionToSubscribe } from 'aob-rabbit-wrapper'

This package exposes following methods | Method | Description | Params | ------ | ------ | ------ | | createRabbitConnectionToPublish | Create connection and bind it with exchange provide | {publishConnectionMap} | createRabbitConnectionToSubscribe | Create connection for subscribing the queues binded with multiple exchanges in rabbit Mq | {publishConnectionMap}

createRabbitConnectionToPublish

Give Options of rabbit and event publisher list for setting up the connection. It will map a callback came from rabbitMq when connection established. Which is mapped in publishConnectionMap.

publishConnectionMap in this map you'll get the publisher callback on which you can publish messgae using the exchange name and routing key For example:

  • Options
const rabbitOptions = () => ({
    host: localhost,
    port: 5672,
    login: rabbitLoginUserName,
    password: rabbitLoginUserPassword,
    connectionTimeout: 10000,
    authMechanism: 'AMQPLAIN',
    vhost: '/',
    noDelay: true,
    ssl: { enabled: false },
  });
  • PublisherList

     eventPublisherList: 
     [ { routingKey: rabbitRoutingKey,
         exchangeName: exchangeNameForPublishingEvent,
         exchangeType: 'topic', // direct, fanout, headers
         eventId: 1 },
       { routingKey: 'rabbitRoutingKey',
         exchangeName: 'exchangeNameForPublishingEvent',
         exchangeType: 'fanout',
         eventId: 2 } ],

createRabbitConnectionToSubscribe

Give subsciber list for setting up the connection to the rabbitMQ. Pass the function reference with the subscriber list which will receive the msg on referenced function.

For example:

  • Subscriber List
    eventSubscriberList: 
     [ { routingKey: 'rabbitRoutingKey',
         exchangeName: 'exchangeNameForSubscribing',
         queueName: 'queueName',
         exchangeType: 'topic' },
       { routingKey: 'rabbitRoutingKey',
         exchangeName: 'exchangeNameForSubscribing',
         queueName: 'queueName',
         exchangeType: 'fanout' } ] }
1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago