Event-driven integration
Communicate facts without hiding ownership.
The problem and the pattern
BookingReserved is a fact about a committed reservation. Consumers decide what that fact means inside their own context. A queue decouples availability but creates delivery, ordering, and schema-evolution responsibilities. State who publishes, who consumes, and how failures are retried or quarantined.
Follow the flow
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
public sealed record BookingReserved(
Guid EventId, Guid BookingId, string TenantId,
DateTimeOffset OccurredAt);Trade-offs
- Asynchronous integration reduces temporal coupling.
- Schemas and delivery guarantees become part of the contract.
- Carry minimal necessary data and avoid secrets in durable events.
When to avoid it
Avoid events for a request that needs an immediate authoritative answer from the owning service.
Your turn
A consumer receives the same event twice and an older event after a newer one. What assumptions should it avoid?
Reveal a worked answer
Do not assume exactly-once or global order. Deduplicate by event identity where needed, use an aggregate version if ordering matters, and define replay behavior. Monitor poison messages rather than retrying forever.