Skip to content

Latest commit

 

History

History
66 lines (46 loc) · 1.79 KB

event-bus.md

File metadata and controls

66 lines (46 loc) · 1.79 KB

RedisSMQ / Docs / EventBus

EventBus

RedisSMQ EventBus allows your applications to subscribe to different system events in a PubSub style.

By default, most of RedisSMQ events are not published to the EventBus. To use the EventBus you need first to enable it from your RedisSMQ Configuration.

See EventBusRedisInstance API for more details.

EventBus Events

Usage

Configuration

const { Configuration } = require('redis-smq');

const config = {
  eventBus: {
    enabled: true,
  }
}

Configuration.getSetConfig(config);

See RedisSMQ Configuration for more details.

Creating an EventBus Instance

import { EventBusRedisInstance } from 'redis-smq';

EventBusRedisInstance.getSetInstance((err, eventBus) => {
  //
});

Subscribing to Events

In the example bellow we are going to subscribe to a TConsumerConsumeMessageEvent event.

eventBus.on('consumer.consumeMessage.messageAcknowledged', (messageId, queue, messageHandlerId, consumerId) => {
  //...
})

Shutting Down the Eventbus Instance

EventBusRedisInstance.shutDown((err) => {
  //
});