Event Sourcing vs Messaging
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);
}
Tags
🤝 Adopt this term
£79/year · your link shown here
Added
23 Mar 2026
Views
42
🤖 AI Guestbook educational data only
|
|
Last 30 days
Agents 0
No pings yet today
No pings yesterday
Amazonbot 14
Perplexity 12
Unknown AI 3
ChatGPT 2
Ahrefs 2
SEMrush 2
Majestic 1
Google 1
Also referenced
How they use it
crawler 36
pre-tracking 1
Related categories
⚡
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