Event Handling¶
Overview¶
-
Event Flow
Understanding how events flow through the system from handlers to processing.
-
Runtime Processing
How events are processed synchronously in the same request context.
-
Parallel Processing
Configuring parallel event processing with concurrency limits.
-
Event Types
DomainEvent vs NotificationEvent and when to use each type.
-
Examples
Complete examples of event handling patterns.
-
Best Practices
Best practices and recommendations for event handling.
Event handlers process domain events that are emitted from command handlers. These events represent something that happened in the domain and trigger side effects like sending notifications, updating read models, or triggering other workflows.
When a command handler processes a request, it can emit domain events through the events property. These events are automatically collected and processed by event handlers registered in the system.
| Aspect | Description |
|---|---|
| Runtime Processing | Events are processed synchronously in the same request context, not asynchronously |
| Automatic Dispatch | Events are automatically dispatched to registered handlers after command execution |
| Parallel Support | Multiple events can be processed in parallel with configurable concurrency limits |
| Side Effects | Event handlers perform side effects without blocking the main command flow |
Prerequisites
Understanding of Request Handlers and Bootstrap is required. Events are emitted by command handlers and processed by event handlers.
Related Topics
- Transaction Outbox — For reliable event delivery to message brokers
- Event Producing — For publishing events to Kafka/RabbitMQ
- FastStream Integration — For consuming events from message brokers