Your application receives an event from Kafka.
It processes the event successfully, updates the database, and prepares to acknowledge the message.
Then the application crashes.
When the application restarts, the broker delivers the same event again.
What happens next?
Does the application recognize that the event has already been processed?
Or does it execute the same business operation a second time?
For some applications, duplicate processing might be harmless. For others, it could mean charging a customer twice, reserving inventory twice, or creating duplicate financial transactions.
In the first article of the NERV Event series, we explored how the Transactional Outbox Pattern helps applications publish events reliably without introducing the dual-write problem.
But reliable publishing solves only one side of event-driven architecture.
The receiving side has its own reliability problem.
How do we reliably process an event when the same event can be delivered more than once?
This is where the Inbox Pattern and idempotent consumers become essential.
Reliable Delivery Does Not Mean Exactly-Once Processing
A common assumption when building event-driven applications is that every published event will be delivered and processed exactly once.
In practice, many reliable messaging architectures operate with at-least-once delivery.
An event may be delivered more than once because of:
- Producer retries
- Consumer crashes
- Network interruptions
- Broker acknowledgment failures
- Consumer group rebalances
- Outbox dispatcher recovery
- Manual event replay
These are not necessarily signs that the messaging infrastructure is broken.
Duplicate delivery is often a consequence of designing a system that prefers retrying an uncertain operation over silently losing an event.
Producer
|
v
Message Broker
|
+------> Event E1
|
+------> Event E1 (redelivery)
|
v
Consumer
The messaging infrastructure helps ensure that the event reaches the consumer.
The consumer must ensure that receiving the event again does not produce an unintended business outcome.
The Consumer-Side Failure Window
Consider a payment service consuming a payment authorization event.
Receive PaymentAuthorized
|
v
Update Payment
|
v
Commit Database Transaction
|
v
Acknowledge Message
Everything appears straightforward until the application crashes between the database commit and the broker acknowledgment.
Receive PaymentAuthorized
|
v
Update Payment
|
v
COMMIT SUCCESSFUL
|
X
APPLICATION CRASH
|
v
Acknowledgment not completed
The database has already committed the business operation.
However, the broker may not know that processing completed.
When the application recovers, the event may be delivered again.
The broker is behaving correctly according to its delivery guarantees.
The database is also behaving correctly according to its transaction guarantees.
The problem exists in the boundary between them.
Neither system independently knows the complete outcome of the operation.
What Is an Idempotent Consumer?
An idempotent consumer is a consumer that can process the same logical event multiple times without producing unintended additional business effects.
Consider these two operations:
payment.setStatus(PaymentStatus.COMPLETED);
And:
account.debit(amount);
The first operation may be naturally idempotent when considered only as a state assignment.
Setting an already completed payment to COMPLETED again does not necessarily change its final state.
However, the surrounding operation might still produce duplicate audit records, notifications, or downstream events.
The second operation is clearly more dangerous.
Executing a debit twice may deduct the amount twice.
Initial Balance: 1,000
First execution:
Debit 100
Balance: 900
Duplicate execution:
Debit 100
Balance: 800
The desired result was 900, regardless of how many times the same logical debit event was delivered.
Idempotency is therefore not simply a property of a Java method.
It is a property of the complete business operation and its observable effects.
The goal is not necessarily to execute the handler only once. The goal is to prevent duplicate execution from producing incorrect business outcomes.
Why Checking Business State Is Sometimes Not Enough
One possible solution is to inspect the current business state before processing an event.
if (payment.isCompleted()) {
return;
}
payment.complete();
This can be useful, especially when the domain already has a well-defined state machine.
But it is not a complete general-purpose event deduplication strategy.
Consider two application instances receiving the same event concurrently.
Consumer A Consumer B
| |
v v
Read payment Read payment
| |
Not completed Not completed
| |
v v
Execute operation Execute operation
Both consumers may observe the same initial state before either commits its changes.
Without an appropriate concurrency mechanism, both may proceed.
Optimistic locking, pessimistic locking, conditional updates, and unique business constraints can help protect domain invariants.
However, event-driven infrastructure also needs a consistent way to identify which logical events have already been received and processed.
This is the responsibility of the Inbox Pattern.
The Inbox Pattern
The Inbox Pattern introduces a durable record of incoming events on the consumer side.
Instead of treating an incoming message as something that exists only inside a message listener, the application records its identity and, depending on the implementation, its payload and processing state.
Message Broker
|
v
Inbox
|
v
Event Handler
|
v
Business Operation
A simplified Inbox table might look like this:
+----------+--------------------+-----------+
| EVENT ID | EVENT TYPE | STATUS |
+----------+--------------------+-----------+
| E-1001 | PaymentAuthorized | PROCESSED |
| E-1002 | OrderCreated | RECEIVED |
| E-1003 | CustomerUpdated | FAILED |
+----------+--------------------+-----------+
When an event arrives, the application can determine whether it represents new work or an event that has already been recorded.
The important distinction is that the Inbox is durable.
Its knowledge of received events survives application restarts, container replacements, and deployments.
Event Identity Is the Foundation of Deduplication
An Inbox requires a stable way to identify an event.
Consider an event envelope:
{
"eventId": "8ec8ac0e-1e90-4a38-b46e-6e785fd01821",
"eventType": "PaymentAuthorized",
"aggregateId": "payment-123",
"correlationId": "workflow-456",
"payload": {
"paymentId": "payment-123",
"amount": 100
}
}
The event ID identifies the logical event.
If the producer retries publishing that event, it should preserve the same event ID.
First delivery:
eventId = E-1001
Second delivery:
eventId = E-1001
Third delivery:
eventId = E-1001
The consumer can recognize all three deliveries as representing the same logical event.
If the producer generates a new event ID every time it retries publishing, the consumer may incorrectly interpret each retry as a new event.
This is one reason event identity should originate when the logical event is created, rather than when an individual delivery attempt occurs.
The event ID is also different from other identifiers commonly found in an event envelope:
- Event ID: Identifies a logical event.
- Aggregate ID: Identifies the affected business entity.
- Correlation ID: Connects related operations within a workflow.
- Causation ID: Identifies the operation or event that caused another event.
- Ordering key: Defines a boundary within which ordering may be required.
These identifiers solve different problems and should not be treated as interchangeable.
Enforce Deduplication in the Database
It is tempting to implement event deduplication using a simple application-level check.
if (!inboxRepository.existsByEventId(eventId)) {
inboxRepository.save(inboxEvent);
process(event);
}
But this introduces a check-then-act race condition.
Two consumers can execute the existence check at the same time.
Consumer A Consumer B
| |
v v
Event does not exist Event does not exist
| |
v v
Insert event Insert event
The database should enforce the uniqueness invariant.
A conceptual PostgreSQL Inbox schema could look like this:
CREATE TABLE inbox_event (
id UUID PRIMARY KEY,
consumer_name VARCHAR(150) NOT NULL,
event_id UUID NOT NULL,
event_type VARCHAR(150) NOT NULL,
payload JSONB NOT NULL,
status VARCHAR(30) NOT NULL,
received_at TIMESTAMPTZ NOT NULL,
processed_at TIMESTAMPTZ,
retry_count INTEGER NOT NULL DEFAULT 0,
next_attempt_at TIMESTAMPTZ,
last_error TEXT,
CONSTRAINT uk_inbox_consumer_event
UNIQUE (consumer_name, event_id)
);
This is an illustrative schema rather than the exact NERV Event database definition.
Notice that uniqueness is scoped to both the consumer identity and the event ID.
The same event may legitimately need to be processed by multiple independent consumers.
PaymentAuthorized (E-1001)
|
+----> Accounting Consumer
|
+----> Notification Consumer
|
+----> Reporting Consumer
Each logical consumer should be able to process the event independently.
But multiple application instances belonging to the same logical consumer should not create independent Inbox records for the same event.
In PostgreSQL, an atomic insert can help enforce this behavior:
INSERT INTO inbox_event (
id,
consumer_name,
event_id,
event_type,
payload,
status,
received_at
)
VALUES (
:id,
:consumerName,
:eventId,
:eventType,
CAST(:payload AS JSONB),
'RECEIVED',
CURRENT_TIMESTAMP
)
ON CONFLICT (consumer_name, event_id)
DO NOTHING;
The unique constraint becomes the final authority on whether the logical event has already been recorded.
An application-level existence check can still be useful as an optimization.
It should not be the only correctness mechanism.
Receiving an Event Is Not the Same as Processing It
This is one of the most important distinctions in the Inbox Pattern.
Suppose the application receives an event and successfully inserts an Inbox record.
Then it crashes before executing the business operation.
Receive Event
|
v
Insert Inbox Record
|
v
COMMIT
|
X
APPLICATION CRASH
|
v
Business operation not executed
When the event is delivered again, the Inbox record already exists.
Should the application simply ignore the event?
Not necessarily.
The event has been received, but it has not been successfully processed.
This is why a durable Inbox can be more useful than a simple table containing processed event IDs.
It allows the infrastructure to distinguish between receipt and completion.
RECEIVED != PROCESSED
The existence of an Inbox record does not automatically mean that the associated business operation has completed.
The Inbox as a Processing State Machine
A more capable Inbox implementation can model the lifecycle of an event.
RECEIVED
|
v
PROCESSING
|
+-------+-------+
| |
v v
PROCESSED FAILED
|
v
RETRY WAIT
|
v
PROCESSING
The exact states depend on the implementation, but the responsibilities are generally similar.
- RECEIVED: The event has been durably recorded.
- PROCESSING: A worker has claimed the event.
- PROCESSED: The required local processing has completed.
- FAILED: Processing encountered an error.
- RETRY WAIT: Processing is waiting for another attempt.
This state machine gives the infrastructure a durable understanding of what happened to an incoming event.
It also introduces responsibilities.
For example, a PROCESSING record cannot be allowed to remain abandoned forever when its worker crashes.
If processing ownership is persisted beyond the claiming transaction, the infrastructure needs an appropriate recovery mechanism.
That may involve expiring claims, leases, ownership tokens, or another explicit recovery strategy.
A status column alone does not solve abandoned work.
Two Ways to Implement the Inbox Pattern
There is no single implementation that fits every application.
Two common approaches are transactional deduplication and durable asynchronous processing.
Approach 1: Transactional Deduplication
The consumer receives an event and processes it within a local database transaction.
BEGIN TRANSACTION
Insert processed event identity
Execute business operation
COMMIT
Acknowledge message
The event identity and the business changes commit together.
If processing fails, both are rolled back.
If the transaction commits but acknowledgment fails, the next delivery can recognize the committed event identity.
This approach is relatively simple and works well when the handler performs short, local database operations.
Approach 2: Durable Inbox Processing
The consumer first records the incoming event durably.
Message Broker
|
v
Persist Inbox Event
|
v
COMMIT
|
v
Acknowledge Message
A separate processing component then executes the business handler.
Inbox
|
v
Processing Worker
|
v
Business Operation
|
v
Update Inbox State
This separates broker delivery from business processing.
The application can independently manage processing attempts, retry schedules, concurrency, and operational visibility.
The tradeoff is additional infrastructure complexity.
Once the broker message has been acknowledged, the application becomes responsible for recovering and processing the durable Inbox record.
Acknowledgment must therefore happen only after the Inbox record has been successfully committed.
Otherwise, the event could be lost between broker acknowledgment and database persistence.
The Inbox Transaction Boundary
Regardless of the implementation approach, the transaction boundary is critical.
Consider the following sequence:
Transaction #1
Update business state
COMMIT
Transaction #2
Mark Inbox PROCESSED
COMMIT
What happens if the application crashes after Transaction #1 commits but before Transaction #2 completes?
The business operation has succeeded, but the Inbox still indicates that processing is incomplete.
A recovery worker may execute the business operation again.
Now consider the reverse:
Transaction #1
Mark Inbox PROCESSED
COMMIT
Transaction #2
Update business state
ROLLBACK
The Inbox says that processing completed successfully.
But the business operation never committed.
The infrastructure may now suppress future attempts to process the event.
Both failure windows can produce incorrect outcomes.
For local transactional operations, the preferred boundary is:
BEGIN TRANSACTION
Execute business operation
Mark Inbox PROCESSED
COMMIT
The business state and Inbox completion commit together.
If either operation fails, the entire transaction rolls back.
The Inbox is not merely a deduplication table. It is part of the application's transaction model.
Implementing the Transaction Boundary with Spring Boot
Spring Boot makes local transaction boundaries relatively easy to express using Spring's transaction management infrastructure.
A simplified processing service might look like this:
@Service
@RequiredArgsConstructor
public class PaymentEventProcessor {
private final InboxRepository inboxRepository;
private final PaymentRepository paymentRepository;
@Transactional
public void process(UUID inboxId) {
InboxEvent inbox = inboxRepository
.findByIdForUpdate(inboxId)
.orElseThrow();
if (inbox.isProcessed()) {
return;
}
PaymentAuthorized event = inbox.readPayload();
Payment payment = paymentRepository
.findById(event.paymentId())
.orElseThrow();
payment.authorize();
inbox.markProcessed();
}
}
In this conceptual example:
- The Inbox record is locked before processing.
- Already completed processing is skipped.
- The business entity is updated.
- The Inbox record is marked as processed.
- Both changes commit within the same local transaction.
The repository locking operation could be expressed using Spring Data JPA:
@Lock(LockModeType.PESSIMISTIC_WRITE)
@Query("""
SELECT i
FROM InboxEvent i
WHERE i.id = :id
""")
Optional<InboxEvent> findByIdForUpdate(
@Param("id") UUID id
);
These examples illustrate the transaction model rather than the public NERV Event API.
For the atomicity guarantee to hold, the Inbox and business persistence operations must participate in the same transaction manager and transactional database resource.
Spring's transaction interception must also be applied correctly.
For example, a self-invocation that bypasses the Spring proxy may prevent an expected transactional boundary from being established.
And if the business operation throws an exception, the transaction must be configured to roll back for that failure.
The presence of an annotation alone does not prove that the required transaction boundary exists.
What Happens When Processing Fails?
Suppose the business handler throws an exception.
BEGIN TRANSACTION
Update business state
Processing fails
ROLLBACK
The business changes and any Inbox completion changes participating in that transaction are rolled back.
However, the infrastructure may still need to record:
- The failed processing attempt
- The retry count
- The failure reason
- The next eligible retry time
- Whether the event requires manual intervention
Those failure details cannot simply be written into the same transaction that is about to roll back.
They need an appropriate transaction boundary of their own.
Processing Transaction
|
v
FAILURE
|
v
ROLLBACK
|
v
Failure Recording Transaction
|
+-- Update retry count
+-- Record failure
+-- Schedule next attempt
|
v
COMMIT
This distinction allows the infrastructure to preserve failure information without accidentally committing incomplete business work.
The failure-recording operation must also respect processing ownership and the current Inbox state so that a stale worker cannot overwrite a newer successful result.
Multiple Application Instances and Concurrent Processing
Production Spring Boot applications rarely run as a single instance.
Several Kubernetes pods may share the same Inbox table.
Inbox Table
|
+-----------+-----------+
| | |
v v v
Pod A Pod B Pod C
Each pod needs to claim eligible work without unnecessarily blocking other workers or processing the same local operation concurrently.
For queue-like database workloads, one useful mechanism is:
SELECT id
FROM inbox_event
WHERE status = 'RECEIVED'
ORDER BY received_at, id
LIMIT 100
FOR UPDATE SKIP LOCKED;
Workers can skip rows already locked by other transactions and continue looking for available work.
However, the locks protect ownership only while the transaction remains active.
If the claiming transaction commits before processing begins, the infrastructure needs durable ownership and recovery semantics to prevent unsafe concurrent processing.
This is an important distinction between database row locking and a persisted processing claim.
Concurrent processing also needs to respect business ordering requirements.
For example, these events may belong to the same payment:
PaymentCreated
|
v
PaymentAuthorized
|
v
PaymentCaptured
Deduplication prevents unintended repeated processing of the same event.
It does not guarantee that different events are processed in the correct business order.
Ordering requires a separate strategy, potentially involving ordering keys, sequence numbers, partitioning, or domain state-transition checks.
Idempotency, concurrency control, and ordering are related but distinct responsibilities.
The Inbox Cannot Make External Side Effects Atomic
The Inbox Pattern becomes more complicated when the business operation crosses a network boundary.
Consider a consumer that calls an external payment provider:
Receive Event
|
v
Call External Payment Provider
|
v
Provider accepts payment
|
X
APPLICATION CRASH
|
v
Inbox completion not committed
The external provider may have already performed the operation.
The local database cannot roll back that external operation.
When the event is retried, the provider might receive the same request again.
This is why Inbox deduplication alone cannot guarantee exactly-once external side effects.
External operations may require additional mechanisms such as:
- Provider-supported idempotency keys
- Stable business operation identifiers
- Provider transaction references
- Status reconciliation
- Explicit workflow state
- Compensating operations where appropriate
An external idempotency key should identify the logical business operation and remain stable across retries.
First Attempt:
operationId = payment-123-capture
Second Attempt:
operationId = payment-123-capture
Third Attempt:
operationId = payment-123-capture
Generating a new operation identifier for every retry would undermine the purpose of external idempotency.
And if the provider does not support idempotency or reliable status reconciliation, an ambiguous failure may require manual intervention rather than an automatic retry.
The Inbox helps the application remember what it knows.
It cannot make an independent external system participate in a local database transaction.
Event Deduplication Is Not Business Idempotency
There is another subtle but important distinction.
Imagine two events:
Event E-1001
PaymentCaptureRequested
paymentId = payment-123
Event E-1002
PaymentCaptureRequested
paymentId = payment-123
The events have different identities.
From the Inbox's perspective, they are two different events.
But from the business domain's perspective, they may represent the same logical payment capture operation.
The Inbox cannot automatically determine whether those operations are semantically equivalent.
That responsibility belongs to the business domain.
Depending on the use case, the domain may need:
- Unique business operation identifiers
- Database uniqueness constraints
- Optimistic locking
- Conditional state transitions
- Domain-specific validation
Event deduplication protects against repeated delivery of the same event. Business idempotency protects against repeated execution of the same logical operation.
A production-ready architecture often needs both.
Combining Inbox and Outbox
The Inbox Pattern becomes particularly powerful when combined with the Transactional Outbox Pattern.
Consider a service that receives a PaymentAuthorized event, updates its business state, and publishes PaymentCompleted.
Incoming Event
|
v
Inbox
|
v
Business Operation
|
v
Outbox
|
v
Outgoing Event
The local processing transaction can include three responsibilities:
BEGIN TRANSACTION
Update business state
Mark Inbox PROCESSED
Insert outgoing Outbox event
COMMIT
The architecture now protects both sides of the local operation.
+-----------------------------------------+
| LOCAL DATABASE TRANSACTION |
| |
| Inbox |
| | |
| v |
| Business State |
| | |
| v |
| Outbox |
| |
+--------------------+--------------------+
|
COMMIT
|
v
Outbox Dispatcher
|
v
Message Broker
If the transaction rolls back:
- The business changes do not commit.
- The Inbox is not marked as successfully processed.
- The outgoing Outbox event is not committed.
If the transaction commits:
- The business changes become durable.
- The Inbox records successful processing.
- The outgoing event becomes available for reliable dispatch.
The next service can then apply the same pattern.
Service A
Business State + Outbox
|
v
Message Broker
|
v
Service B
Inbox + Business State + Outbox
|
v
Message Broker
|
v
Service C
Inbox + Business State
This creates a sequence of durable handoffs between services.
Each service owns its local consistency boundary.
No global distributed database transaction is required.
Inbox Versus Dead-Letter Queue
A common question is whether an Inbox is necessary when the message broker already supports a Dead-Letter Queue.
These mechanisms serve different responsibilities.
A Dead-Letter Queue provides a destination for messages that could not be delivered or processed according to a configured failure policy.
An Inbox can provide a durable application-side record of the event's processing lifecycle.
| Responsibility | Inbox | Dead-Letter Queue |
|---|---|---|
| Event deduplication | Supported by design | Not its primary purpose |
| Successful processing history | Can be retained | Not normally provided |
| Local transaction integration | Possible | Not inherently atomic with the database |
| Failed message isolation | Through processing state | Primary responsibility |
| Application-controlled retries | Can be implemented | Depends on broker and application |
| Business processing visibility | Can expose detailed state | Generally message-oriented |
A Dead-Letter Queue can complement an Inbox.
It does not automatically replace the Inbox's transaction and idempotency responsibilities.
In NERV Event, durable application-side processing state is an important part of the reliability model.
Broker-specific failure mechanisms can complement that model without becoming the only source of truth about processing outcomes.
Inbox Retention Is a Correctness Decision
An Inbox table cannot necessarily grow forever.
Eventually, successfully processed events may need to be archived or removed.
But deleting an Inbox record also removes part of the application's deduplication history.
Day 1:
Event E-1001 processed
Day 30:
Inbox record deleted
Day 45:
Event E-1001 replayed
If the application relies exclusively on the Inbox record for deduplication, the replayed event may now be treated as new work.
Inbox retention must therefore consider:
- Broker message retention
- Maximum expected redelivery windows
- Manual replay policies
- Producer retry behavior
- Business idempotency requirements
- Audit and data-retention obligations
- Storage and indexing costs
For critical business operations, domain-level idempotency may need to survive much longer than the infrastructure's Inbox retention period.
Retention is not merely a database housekeeping task.
It defines how long a particular deduplication guarantee remains valid.
Observability: Knowing What Happened to an Event
One of the operational advantages of a durable Inbox is that event processing becomes inspectable.
Imagine a production incident where a payment remains in an unexpected state.
Without durable processing information, an engineer might need to search application logs across multiple pods, inspect broker offsets, and reconstruct the sequence of operations manually.
With a well-designed Inbox, the infrastructure can help answer questions such as:
- Was the event received?
- When was it received?
- Which logical consumer owns it?
- Has processing completed?
- How many attempts have been made?
- What caused the last failure?
- When is the next retry scheduled?
- Is processing ownership stale?
- Does the event require manual intervention?
Useful operational metrics may include:
- Pending Inbox event count
- Age of the oldest pending event
- Successful processing rate
- Failed processing rate
- Retry attempt count
- Duplicate delivery count
- Processing latency
- Abandoned or expired processing claims
These metrics should be designed carefully to avoid high-cardinality labels, especially event IDs and business identifiers.
Detailed identifiers belong in appropriate logs, traces, and diagnostic records rather than unbounded metric dimensions.
Reliability is not only about recovering from failure.
It is also about understanding the current state of the system when something goes wrong.
Testing an Idempotent Consumer
A successful happy-path test does not prove that a consumer is reliable.
The interesting behavior appears around failure boundaries.
A production-oriented test suite should include scenarios such as:
| Scenario | Expected Behavior |
|---|---|
| Same event delivered twice | No unintended duplicate business effect |
| Concurrent duplicate delivery | Uniqueness and processing ownership remain correct |
| Crash before Inbox commit | Unacknowledged event remains recoverable |
| Crash after Inbox commit | Durable pending work remains recoverable |
| Business transaction rollback | Inbox completion does not commit |
| Crash after successful processing commit | Redelivery does not repeat committed local effects |
| Worker crashes after claiming an event | Abandoned processing ownership can be recovered |
| External operation succeeds before a timeout | Retry or reconciliation avoids unintended duplicate effects |
| Different events represent the same business operation | Domain-level idempotency protects the business invariant |
| Replay after Inbox retention expires | Behavior follows the documented replay and idempotency policy |
These scenarios are particularly valuable when tested against a real transactional database using integration tests.
Mock-based tests can validate handler behavior, but they cannot fully demonstrate database locking, transaction rollback, unique constraint enforcement, or concurrent processing semantics.
How NERV Event Approaches the Inbox Pattern
One of the motivations behind building NERV Event was to avoid reimplementing event reliability infrastructure independently in every Spring Boot application.
Business applications should primarily focus on business operations.
They should not need to repeatedly design their own infrastructure for:
- Incoming event identity
- Durable event receipt
- Duplicate detection
- Processing lifecycle management
- Retry handling
- Transaction boundaries
- Concurrent worker coordination
- Failure inspection
- Operational visibility
NERV EVENT
INBOX OUTBOX
| ^
v |
+--- Business Logic --+
Incoming Reliability Outgoing Reliability
The Inbox protects the receiving side of an event-driven application.
The Outbox protects the publishing side.
The application's transaction boundaries connect them to business state.
Broker integrations such as Kafka and Amazon SQS provide message transport, while the application-side infrastructure addresses reliability concerns that transport alone cannot solve.
This separation also helps keep business processing concerns distinct from broker-specific delivery behavior.
When Is an Inbox Worth the Complexity?
Not every event consumer requires a complete durable Inbox infrastructure.
A naturally idempotent consumer performing a simple operation may only need domain-level protection.
A short transactional consumer may be adequately protected by a processed-event table with a unique constraint.
A more complete durable Inbox becomes attractive when the application needs:
- Reliable processing of critical business events
- Recovery across application restarts
- Independent processing retries
- Multiple concurrent application instances
- Detailed processing and failure visibility
- Long-running or multi-step business workflows
- Controlled replay and operational intervention
The decision should be driven by the business consequences of duplicate processing, lost work, and uncertain outcomes.
A durable Inbox introduces database writes, storage requirements, retention policies, and operational responsibilities.
Those costs should be justified by the reliability guarantees the application actually needs.
The Bigger Lesson
When I started building event-driven infrastructure, it was easy to think about reliability primarily in terms of the message broker.
Did Kafka receive the message?
Did the consumer acknowledge it?
Did the broker retry delivery?
Those are important questions.
But they do not fully describe whether the business operation completed correctly.
The broker knows about message delivery.
The database knows about committed business state.
The application must establish the relationship between them.
The Inbox Pattern helps make that relationship durable, transactional, and observable.
Combined with the Transactional Outbox Pattern, it allows an event-driven application to reason about both incoming and outgoing reliability.
Reliable Publishing
+
Reliable Consumption
+
Business Idempotency
+
Explicit Transaction Boundaries
=
Recoverable Event-Driven Workflows
The goal is not to pretend that failures, retries, and duplicate deliveries will never happen.
The goal is to build an architecture that continues to behave correctly when they do.
A reliable event-driven system is not one that never receives the same event twice. It is one that knows what receiving the same event twice should mean.
About NERV Event
NERV Event is an open-source event-driven infrastructure library for Spring Boot focused on reliable event publishing, processing, and operational resilience.
Its architecture brings together the Transactional Outbox Pattern, Inbox processing, idempotency, retries, ordering, multi-instance processing, broker integrations, and operational visibility.
Explore the source code, documentation, and implementation:
NERV Event is part of NERV — Next-Generation Engineering for Runtime Velocity.
Further Reading
- Idempotent Consumer Pattern
- Transactional Outbox Pattern
- Spring Framework Transaction Management
- Apache Kafka Documentation
- PostgreSQL INSERT and ON CONFLICT
- PostgreSQL SELECT and Locking Clauses

Post a Comment