Skip to content

Event Handling

Overview

  • Event Flow

    Understanding how events flow through the system from handlers to processing.

    Read More

  • Runtime Processing

    How events are processed synchronously in the same request context.

    Read More

  • Parallel Processing

    Configuring parallel event processing with concurrency limits.

    Read More

  • Event Types

    DomainEvent vs NotificationEvent and when to use each type.

    Read More

  • Examples

    Complete examples of event handling patterns.

    Read More

  • Best Practices

    Best practices and recommendations for event handling.

    Read More

  • Fallback

    Fallback handler when primary event handler fails or circuit breaker is open.

    Read More

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. Event handlers can in turn produce follow-up events via their own events property; these follow-ups are processed in the same pipeline (sequential BFS or parallel with semaphore), enabling multi-level event chains.

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
Event Propagation Handlers can return follow-up events via events; they are processed in the same run (BFS or parallel)
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