Production-ready outbox pattern in TypeScript
📜Hermes is the god of reliable deliveries. His two insignias are an outbox and a letter. Just write a message, put it into an envoy, and put it in the box. That's it! You don't need prayers, keeping crossed fingers and hope. Your message will be delivered for sure! Hermes is on it!
Hermes is a production-ready implementation of the Outbox Pattern.
Use it to provide at-least-once delivery to your system's consumers, so depite a timeout or a message broker outage, Hermes will keep trying to deliver that message to the broker.
After Chris Richardson:
At-least once delivery guarantees that a message broker will deliver a message to a consumer even if errors occur. One side-effect, however, is that the consumer can be invoked repeatedly for the same message
The Outbox pattern makes an atomic operation from a database operation (e.g. modifying an Aggregate or Entity) and publishing an event thanks to the fact that the event publishing happens first in the database along with the operation. Later Hermes makes sure that event goes to the message broker.
If you work with MongoDB, then:
npm i @arturwojnar/hermes @arturwojnar/hermes-mongodb
Visit Hermes docs.
Head over to the discussions to share your ideas.
Special thanks to Magdalena Gańczorz for helping me with Hermes logo.