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.
- TConsumerEvent
- TConsumerHeartbeatEvent
- TConsumerMessageHandlerRunnerEvent
- TConsumerMessageHandlerEvent
- TConsumerConsumeMessageEvent
- TConsumerDequeueMessageEvent
- TProducerEvent
- TQueueEvent
const { Configuration } = require('redis-smq');
const config = {
eventBus: {
enabled: true,
}
}
Configuration.getSetConfig(config);
See RedisSMQ Configuration for more details.
import { EventBusRedisInstance } from 'redis-smq';
EventBusRedisInstance.getSetInstance((err, eventBus) => {
//
});
In the example bellow we are going to subscribe to a TConsumerConsumeMessageEvent event.
eventBus.on('consumer.consumeMessage.messageAcknowledged', (messageId, queue, messageHandlerId, consumerId) => {
//...
})
EventBusRedisInstance.shutDown((err) => {
//
});