Best Practices¶
-
Back to Transactional Outbox Overview
Return to the Transactional Outbox overview page with all topics.
Overview¶
- Always commit — Always call
commit()after adding events (including afterget_many/ publish loops) - Use transactions — Ensure outbox operations are in the same transaction as business logic
- Register events — Register all event types on an
OutboxedEventMap(prefer an isolated instance) - Handle failures — Implement retry logic in the publisher process
- Monitor status — Track
NOT_PRODUCEDevents for debugging. Rows that fail to deserialize (or whoseevent_nameis not registered) are markedNOT_PRODUCEDand spend the sameflush_counterbudget as broker publish failures, so they stop filling the selectable batch after the limit - Use compression — Enable compression for large payloads
- Batch processing — Process events in batches for efficiency
-
Codecs — Keep JSON as the default; register Protobuf (or a custom
EventCodec) only per event that needs it. Changing a codec for an already-registered name does not rewrite pending rows — keep the reader compatible with bytes already stored, or drain the outbox first -
Event Producing — How to produce events without outbox
- FastStream Integration — Kafka and RabbitMQ message broker configuration
- Dependency Injection — How to inject outbox repository
- Protobuf Integration — Opt-in Protobuf codecs for outbox and brokers