The core pattern ensures events are only published if data operations succeed:
awaitsql.begin(async (sql) => { // Business logic awaitdb.collection('users').insertOne(user, sql)
// Event publishing - same transaction! awaitoutbox.queue(userCreatedEvent, { tx:sql }) }) // Either both succeed or both fail - no inconsistency possible
At-Least-Once Delivery
Hermes guarantees delivery via the publish callback:
Hermes PostgreSQL
Production-ready implementation of the Outbox Pattern for PostgreSQL using Logical Replication.
Features
Installation
Quick Start
Key Concepts
Transactional Event Publishing
The core pattern ensures events are only published if data operations succeed:
At-Least-Once Delivery
Hermes guarantees delivery via the publish callback:
Idempotent Handlers
Since messages may be delivered multiple times, handlers must be idempotent:
PostgreSQL Configuration
Enable logical replication in your PostgreSQL configuration:
Advanced Features
Async Outbox for Compensations
Use a separate async outbox for non-critical messages:
Horizontal Scaling with Partition Keys
Scale horizontally by partitioning messages:
Architecture
Hermes PostgreSQL leverages PostgreSQL's built-in Logical Replication:
publishcallback for each messageError Handling
Best Practices
Links
See