Step 6 — Outbox, saga and scheduler

Publish and commit together, compensate a multi-step workflow, deliver later.

← step 5 · step 7 →

Run it

One command, whichever language you came for. The image carries the toolchain, the library and RabbitMQ; the management UI is on http://localhost:15672 (guest/guest) while it runs, and --keep holds it open afterwards.

docker run --rm -p 15672:15672 ghcr.io/acemq-company/acemq-tutorials-java:0.7.15 step 6
docker run --rm -p 15672:15672 ghcr.io/acemq-company/acemq-tutorials-python:0.7.12 step 6
docker run --rm -p 15672:15672 ghcr.io/acemq-company/acemq-tutorials-ruby:0.7.14 step 6
docker run --rm -p 15672:15672 ghcr.io/acemq-company/acemq-tutorials-dotnet:0.7.13 step 6
docker run --rm -p 15672:15672 ghcr.io/acemq-company/acemq-tutorials-go:0.9.9 step 6

Side by side

Java Python Ruby .NET Go
Example 06-transactional-outbox
12-saga
13-scheduling
03-transactional-outbox
06-saga
05-scheduler
03-outbox
06-saga
07-scheduling
05-transactional-outbox-csharp
04-saga-csharp
05-scheduling-csharp
03-outbox
04-saga
05-scheduling
Tutorial: exactly once Java Python Ruby .NET Go
Patterns Java Python Ruby .NET Go

Java

acemq-java-amqp 0.7.15, acemq-java-amqp-examples examples-v0.7.15.

basic/06-transactional-outbox

Saving an order and publishing an event are two writes to two systems. Done in sequence, a crash in between leaves one done and the other not — an order nobody was told about, or a notification for an order that does not exist. Retrying does not help: the process that would retry is the one that died.

intermediate/12-saga

Three services, no shared transaction, and what happens when the third one says no. Three runs: one that works, one that is undone, and one that cannot be.

intermediate/13-scheduling

Three reminders: one already overdue, one in three seconds, one in five. No scheduler process, no plugin, no cron.

Python

acemq-python-amqp 0.7.12, acemq-python-amqp-examples examples-v0.7.12.

intermediate/03-transactional-outbox

A message written in the same transaction as the work, and a relay publishing it after.

intermediate/06-saga

Three systems, no shared transaction, and what happens when the third one says no.

intermediate/05-scheduler

Deliver this message later — and the long one does not hold up the short one.

Ruby

acemq-ruby-amqp 0.7.14, acemq-ruby-amqp-examples examples-v0.7.14.

intermediate/03-outbox

Two accounts opened: one that commits and one that is rolled back by a compliance check. One message is published.

intermediate/06-saga

Two bookings arrive as messages. One goes through; the other fails at the last step, and the three that already happened are undone in reverse.

intermediate/07-scheduling

Three reminders: one already overdue, one in three seconds, one in five. No scheduler process, no plugin, no cron.

.NET

acemq-dotnet-amqp 0.7.13, acemq-dotnet-amqp-examples examples-v0.7.13.

basic/05-transactional-outbox-csharp

Two order messages written into an outbox in the same transaction as the orders themselves, and a relay that publishes them afterwards and marks them done once the broker has confirmed — so a process that dies between writing a row and announcing it can no longer leave the row without the announcement, or the announcement without the row.

intermediate/04-saga-csharp

Reserving stock, taking a payment and booking a courier are three services with three databases. There is no transaction across them, so "roll it back" is not something a database can be asked to do — it has to be done by running the opposite of each step that succeeded, in reverse.

intermediate/05-scheduling-csharp

Three reminders: one already overdue, one in three seconds, one in five. No scheduler process, no cron, and no broker plugin.

Go

acemq-go-amqp 0.9.9, acemq-go-amqp-examples examples-v0.9.9.

intermediate/03-outbox

A service that writes to its database and then publishes has two steps that can fail separately, and the gap between them is where messages are lost or invented. This example records an order event in an outbox instead of publishing it, and a relay publishes what was recorded and removes it only once the broker confirms.

intermediate/04-saga

Three runs of the same order: one that works, one where the payment is refused, and one where the undo itself fails.

intermediate/05-scheduling

Three reminders: one already overdue, one in three seconds, one in five. No scheduler process, no plugin, no cron.