Django · PostgreSQL · At-least-once delivery

One commit.
Nothing lost.

A transactional outbox and reliable background jobs for Django on PostgreSQL. Publish an event or enqueue a job in the same transaction as the data it's about. If the transaction commits, the work happens — even if the process dies on the next line.

CI PyPI license Python Django PostgreSQL
from django.db import transaction
from reliable_outbox import publish, job

@job(retries=5, backoff="exponential")
def send_receipt(order_id: int) -> None: ...

with transaction.atomic():
    order.save()
    publish("order.created", {"id": order.id}, key=f"order-{order.id}")
    send_receipt.enqueue(order.id)   # runs only if this transaction commits

Two writes, one transaction

Saving to the database and telling another system about it are two writes to two systems — and no transaction spans both. The outbox pattern turns it into one: the event is a row in the same database, in the same transaction; a worker delivers it afterwards and retries until it succeeds.

Events & jobs

Publish events routed to a destination, or enqueue background jobs with retries, backoff and timeouts — all through the same outbox row.

Per-key ordering

Messages sharing a key run one at a time, in insertion order, across every worker, through retries. Different keys run in parallel.

Dead-lettering & requeue

Permanent failures land in a dead-letter state with their last error and traceback, and can be requeued from the CLI or the admin.

Pluggable destinations

Local handlers, Redis Streams, Kafka or signed webhooks — route events by pattern, no broker required for the simple case.

Inbox deduplication

At-least-once means consumers see duplicates. Claim a message id in the same transaction as the work and a duplicate becomes a no-op.

No broker to run

NOTIFY wakes idle workers on commit, with polling as a fallback. Coordination is row locks alone — run as many workers as you like.

What's guaranteed

Every promise marked Yes is exercised by a test against a real PostgreSQL server: rollback, crash and lease expiry, concurrent workers, ordering, backoff, dead-lettering and webhook signatures.

Guaranteed?
Rolled-back transaction publishes nothingYes
Nothing lost once committedYes
Per-key order across all workersYes
External side effects happen exactly onceNo — at least once
Global order across keysNo