Prompt

How do I build an event-driven architecture with at-least-once delivery?

Technology / Data Infrastructure1 observationLast seen Oct 24, 2026

Latest observation

Oct 24, 2026OpenAI APIWeb search: off

Building an event-driven architecture with at-least-once delivery means designing your system so that every event is delivered one or more times, and consumers are safe to process duplicates.

Core idea

At-least-once delivery usually comes from this rule:

  • Do not acknowledge an event until it has been durably processed
  • If processing fails or the ack is lost, the message gets retried

That means duplicates are expected, so your system must be idempotent.


1) Use a durable message broker

Choose a broker that supports persistence and retries, for example:

  • Kafka
  • RabbitMQ
  • AWS SQS
  • Google Pub/Sub
  • Azure Service Bus

The broker should:

  • persist messages to disk
  • redeliver unacked messages
  • support consumer offsets / acknowledgments / leases

2) Make producers reliable

When publishing an event:

  • write the event to the broker durably
  • include a unique event_id
  • ideally use a schema/version for payload compatibility

Example event fields:

{
  "event_id": "uuid-123",
  "event_type": "OrderCreated",
  "timestamp": "2026-10-24T12:00:00Z",
  "aggregate_id": "order-789",
  "version": 3,
  "payload": { ... }
}

Important

If your producer also writes to a database, avoid the “dual write” problem.

Use one of these patterns:

  • Transactional outbox
  • CDC (change data capture)
  • Write event in same transaction as state change, then relay it asynchronously

3) Design consumers to be idempotent

Since duplicates happen, the consumer must safely handle repeated events.

Common approaches:

A. Deduplication table

Store processed event_ids in a database.

Flow:

  1. Receive event
  2. Check whether event_id was already processed
  3. If yes, skip
  4. If no, process and store event_id

B. Idempotent updates

Design operations so repeating them has no extra effect.

Examples:

  • set order status to SHIPPED instead of incrementing a counter
  • upsert records by key
  • use version checks / optimistic concurrency

C. Natural keys + unique constraints

Use database constraints so duplicates fail harmlessly.

Example:

  • unique constraint on (event_id)
  • unique constraint on (order_id, version)

4) Ack only after successful processing

The consumer should:

  1. receive event
  2. process it
  3. commit DB changes
  4. acknowledge message

If you ack before the DB commit, a crash can lose data. If you commit before ack, a crash can cause duplicate delivery — which is okay if idempotent.


5) Handle poison messages and retries

Some messages will always fail due to bad data or code bugs.

Implement:

  • retry with backoff
  • max retry count
  • dead-letter queue (DLQ) / poison queue

Pattern:

  • temporary failure → retry
  • permanent failure → send to DLQ for manual inspection

6) Preserve ordering only where needed

At-least-once delivery and strict ordering are different concerns.

If ordering matters:

  • partition events by a key, such as aggregate_id
  • process one partition/key serially
  • use event version numbers to detect out-of-order updates

If ordering does not matter:

  • scale consumers horizontally more easily

7) Make side effects safe

If event handling triggers external effects, duplicates can be dangerous:

  • sending emails
  • charging credit cards
  • provisioning resources

For these, use:

  • idempotency keys with downstream APIs
  • a local ledger or state machine
  • “exactly once effect” semantics at the application layer, even if transport is at-least-once

Example:

  • payment API call includes idempotency_key = event_id
  • email service stores sent-message IDs to prevent duplicates

8) Observe and monitor

Track:

  • consumer lag
  • retry counts
  • DLQ volume
  • duplicate rate
  • processing latency
  • success/failure per event type

This helps you spot:

  • stuck consumers
  • poison messages
  • duplicate storms
  • backlog growth

Reference processing flow

A robust consumer flow looks like this:

  1. Receive event from broker
  2. Start DB transaction
  3. Check deduplication store
  4. If already processed, commit/skip and ack
  5. Apply business logic
  6. Persist state changes
  7. Record event as processed
  8. Commit transaction
  9. Ack the broker message

Simple design rule

If you want at-least-once delivery, build for this assumption:

“Any event may be delivered multiple times, and any consumer may crash at any point.”

That leads to:

  • durable broker
  • idempotent consumers
  • transactional persistence
  • retries + DLQ
  • deduplication where needed

Minimal pattern summary

  • Broker: durable and retry-capable
  • Producer: unique event IDs + transactional outbox if needed
  • Consumer: process transactionally, then ack
  • Data model: idempotent or deduplicated
  • Failures: retry, backoff, DLQ
  • External effects: idempotency keys

If you want, I can also give you:

  1. a Kafka-based reference architecture,
  2. a Node.js / Python consumer example, or
  3. a transactional outbox implementation.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.