Back to Docs
Recipe

Pub/Sub Patterns

Decouple services with event-driven messaging. This recipe covers topic-based routing, dead-letter queues, and exactly-once delivery guarantees using Meridian's built-in broker.

Topic Declaration

Define durable topics with configurable retention and partitioning. Each topic maps to a logical channel; subscribers bind via push or pull models.

meridian topic create orders.events --partitions 6 --retention 72h

Fan-Out Delivery

A single published message fans out to every active subscription. Use subscription filters to route only relevant payloads to each consumer group.

meridian sub create inventory-sync --topic orders.events --filter "type=fulfilled"

Dead-Letter Handling

Messages that exceed retry thresholds land in a per-subscription DLQ. Inspect, replay, or purge them without losing visibility.

meridian dlq list inventory-sync --limit 50

Exactly-Once Semantics

Enable idempotency keys and transactional outboxes to prevent duplicate processing. Meridian deduplicates within a configurable window per message ID.

Next step: Event Sourcing Recipe — persist every state change as an immutable event stream.