You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add database-backed event processing with Outbox pattern
This commit introduces a database-backed outbox pattern for reliable event
processing as an alternative to direct Kinesis delivery. This enables
transactional event guarantees and better reliability.
Key changes:
- Add Journaled::Outbox::Adapter for database-backed event delivery
- Add Journaled::Outbox::Event model with UUID v7 primary keys
- Add Journaled::Outbox::Worker for processing events from the database
- Add Journaled::Outbox::BatchProcessor for batch delivery to Kinesis
- Add Journaled::Outbox::MetricEmitter for monitoring queue health
- Add generators for creating database tables and UUID v7 support
- Add rake task for running the worker process
- Update KinesisBatchSender to work with database events
- Add comprehensive test coverage for all outbox components
The outbox pattern stores events in PostgreSQL with guaranteed ordering
using UUID v7 timestamps, then processes them asynchronously with
configurable retry logic and detailed metrics emission.
@@ -52,6 +54,8 @@ to use one of the following queue adapters:
52
54
53
55
This configuration isn't necessary for applications running Rails8+.
54
56
57
+
**Note:**If you plan to use the [Database-BackedEventProcessing](#database-backed-event-processing-optional) (Outbox adapter), you can skip this step entirely, as the Outbox adapter does not use ActiveJob.
58
+
55
59
2. To integrate Journaled into your application, simply include the gem in your
56
60
app's Gemfile.
57
61
@@ -129,6 +133,37 @@ Journaling provides a number of different configuation options that can be set i
129
133
130
134
The number of seconds before the :http_handler should timeout while waiting for a HTTP response.
Determines how events are delivered to Kinesis. Two options are available:
139
+
140
+
- **`Journaled::DeliveryAdapters::ActiveJobAdapter`** (default) - Enqueues events to ActiveJob. Requires a DB-backed queue adapter (see Installation).
141
+
142
+
- **`Journaled::Outbox::Adapter`** - Stores events in a database table and processes them via separate worker daemons. See [Database-Backed Event Processing](#database-backed-event-processing-optional) for setup instructions.
**Only relevant when using `Journaled::Outbox::Adapter`.**
153
+
154
+
Specifies which ActiveRecord base class the Outbox event storage model (`Journaled::Outbox::Event`) should use for its database connection. This is useful for multi-database setups where you want to store events in a separate database.
# Optional: Customize worker behavior (these are the defaults)
214
+
Journaled.worker_batch_size = 500 # Max events per Kinesis batch (Kinesis API limit)
215
+
Journaled.worker_poll_interval = 5 # Seconds between polls
216
+
Journaled.worker_max_attempts = 3 # Retries before marking as failed
217
+
```
218
+
219
+
**Note:**Whenusing the Outbox adapter, you do**not** need to configure an ActiveJob queue adapter (skip step 1 of Installation). TheOutbox adapter uses the `journaled_outbox_events` table for event storage and its own worker daemons for processing, making it independent of ActiveJob. Transactional batching still works seamlessly with the Outbox adapter.
0 commit comments