2.0.6 • Published 3 years ago

adonis-amqp-eventbus v2.0.6

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

adonis-amqp-eventbus

A beta implementation of AMQP eventbus for Adonis. This is also based on this implimentation adonisjs-rabbitmq

Installation

adonis install adonis-amqp-eventbus

Register provider

Register provider inside start/app.js file.

const providers = [
  'adonis-amqp-eventbus/providers/AmqpEventBusProvider'
]

Publish

const AmqpProducer = use('AmqpProducer');

/* Context message must be a string. If this is an object you may use JSON.stringify()*/
AmqpProducer.publish('example-exchange', 'routing-key', 'context-message');

Consume

This will boot on startup. start/hooks.js

const { hooks } = require('@adonisjs/ignitor');

hooks.after.httpServer(() => {
  use('AmqpConsumer');
})

Config

module.exports = {
  /*
  | RabbitMQ Connection String
  |
  */
  rabbitmq_host: Env.get('RABBITMQ_HOST') || 'localhost',
  rabbitmq_port: Env.get('RABBITMQ_PORT') || '5672',
  rabbitmq_user: Env.get('RABBITMQ_USER') || 'user',
  rabbitmq_password: Env.get('RABBITMQ_PASSWORD') || 'password',
  rabbitmq_protocol: Env.get('RABBITMQ_PROTOCOL') || 'amqp',

  /*
  * Consumer to listeners
  * 
  * This will automatically create an exchange and queue. Also, bind them automatically as well
  */
  consumers: [
    {
      queueName: 'user-registered',
      exchange: 'user-exchange',
      handler: (ch) => (context) => {
        //...your handler here
        ch.ack(context)
      })
    }
  ]
}

The config file is saved as config/eventbus.js.

2.0.5

3 years ago

2.0.6

3 years ago

2.0.4

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.11.1

4 years ago

1.11.0

4 years ago

1.10.8

4 years ago

1.10.7

4 years ago

1.10.6

4 years ago

1.10.5

4 years ago

1.10.4

4 years ago

1.10.3

4 years ago

1.10.2

4 years ago

1.10.1

4 years ago

1.10.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago