← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

Event Sourcing vs Messaging

Messaging Intermediate
debt(d9/e7/b7/t7)
d9 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'silent in production until users hit it' (d9). The detection_hints field explicitly states automated: no, and the code pattern hints (EventStore|appendEvent|DomainEvent) merely identify event sourcing usage, not whether it was chosen for the wrong reasons. There is no tool that can detect an architectural category mistake — choosing event sourcing where simple messaging suffices is invisible until the system is in production and the complexity overhead becomes a maintenance and performance burden.

e7 Effort Remediation debt — work required to fix once spotted

Closest to 'cross-cutting refactor across the codebase' (e7). The quick_fix advises using event sourcing only where genuinely needed, but reversing that choice after adoption means replacing the persistence strategy, rebuilding projections, removing CQRS scaffolding, and redesigning inter-service communication patterns. This is not a single-component fix — it touches storage, domain models, query layers, and service boundaries across the codebase.

b7 Burden Structural debt — long-term weight of choosing wrong

Closest to 'strong gravitational pull' (b7). The tags (event-sourcing, cqrs, architecture) and applies_to (web, cli, queue-worker) indicate this is a system-wide architectural choice. Once event sourcing is adopted, every future change — new features, schema migrations, query optimization, service additions — is shaped by the event store, projection model, and versioning requirements. The common_mistakes (no versioning, no CQRS) confirm the persistent productivity tax imposed on all maintainers.

t7 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'serious trap — contradicts how a similar concept works elsewhere' (t7). The misconception field explicitly states the canonical wrong belief: developers conflate event sourcing (a persistence strategy) with messaging (a communication strategy), treating them as alternatives rather than complements. This is a well-documented architectural confusion where the 'obvious' interpretation — both deal with events, so they solve the same problem — directly contradicts reality, leading to significant wrong architectural choices.

About DEBT scoring →

TL;DR

Event sourcing stores all state changes as immutable events (the source of truth) — messaging delivers events between services. They complement each other but serve different purposes.

Explanation

Event sourcing: the event log IS the database — current state is derived by replaying events. No UPDATE/DELETE, only append. Benefits: full audit trail, time travel, event replay, projections. Kafka can serve as the event store. Messaging: events are transient notifications between services — usually not the source of truth. Combining: store events with event sourcing (for your domain), publish to a message broker for other services. CQRS + Event Sourcing: command side appends events, query side builds projections from event stream. PHP: EventSauce, Prooph, Broadway libraries.

Common Misconception

Event sourcing and messaging solve the same problem — event sourcing is a persistence strategy; messaging is a communication strategy. They're complementary, not alternatives.

Why It Matters

Confusing event sourcing with messaging leads to wrong architectural choices — event sourcing has significant complexity overhead not justified by simple notification use cases.

Common Mistakes

  • Using event sourcing where a simple audit log suffices — add complexity without benefit.
  • Not versioning events — events are forever, schemas change.
  • Event sourcing without CQRS — query performance degrades without read projections.

Code Examples

✗ Vulnerable
// Treating messaging as event sourcing — no persistence:
$broker->publish('user.updated', $event); // If broker goes down, history lost
✓ Fixed
// Event sourcing — events ARE the state:
$user->applyEvent(new UserEmailChanged($userId, $newEmail));
$eventStore->append($user->getDomainEvents()); // Persistent, immutable

// Then publish to broker for other services:
foreach ($user->getDomainEvents() as $event) {
    $broker->publish($event);
}

Added 23 Mar 2026
Views 74
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 3 pings F 1 ping S 4 pings S 1 ping M 0 pings T 1 ping W 0 pings T 0 pings F 1 ping S 0 pings S 1 ping M 0 pings T 1 ping W 0 pings T 0 pings F 1 ping S 0 pings S 1 ping M 1 ping T 0 pings W
No pings yet today
Bing 1
Amazonbot 17 Perplexity 12 Scrapy 8 Ahrefs 4 SEMrush 4 Unknown AI 3 Google 3 ChatGPT 2 Majestic 2 PetalBot 2 Claude 1 Meta AI 1 Bing 1
crawler 58 crawler_json 1 pre-tracking 1
DEV INTEL Tools & Severity
🔵 Info ⚙ Fix effort: High
⚡ Quick Fix
Use event sourcing only for domains that genuinely need audit trails, time travel, or complex business event histories. Use messaging for simpler inter-service notification.
📦 Applies To
web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
EventStore|appendEvent|DomainEvent
Auto-detectable: ✗ No
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: High Context: File


✓ schema.org compliant