@moirae/rabbitmq
v0.6.0
Published
A Moirae publisher leveraging RabbitMQ as a transport layer providing: - RabbitMQConnection: a connection instance for RabbitMQ. Can be resused (e.g. PubSub) - RabbitMQPublisher: Override the default `PUBLISHER` token - RabbitPubSubEngine: Override the de
Downloads
4
Readme
@moirae/rabbitmq
A Moirae publisher leveraging RabbitMQ as a transport layer providing:
- RabbitMQConnection: a connection instance for RabbitMQ. Can be resused (e.g. PubSub)
- RabbitMQPublisher: Override the default
PUBLISHER
token - RabbitPubSubEngine: Override the default
EVENT_PUBSUB_ENGINE
token
Lifecycle
onModuleInit
- Initialize connection to RabbitMQ
onApplicationBootstrap
- Initialize RabbitMQPublisher
- Initialize RabbitPubSubEngine
beforeApplicationShutdown
- Tear down RabbitMQPublisher
- Tear down RabbitPubSubEngine
onApplicationShutdown
- Tear down connection to RabbitMQ
External Systems
In cases where events should be published externally to the application (in the case of analytics for instance), there are two ways to subscribe to the event stream.
Pre-processing
To subscribe pre-processing, meaning before the core application has processed but after storing the event, first create a queue for the service and bind the queue to the event store exchange.
Related: Fanout Exchange
Post-processing
To subscribe post-processing within the core application, simply create a queue and bind it to the pubsub exchange.