Interface IIntegrationEventHandler<TEvent>
Handles an IIntegrationEvent - the in-process consumer side of the external contract. Implementations are resolved via DI and invoked once per matching event by the default IIntegrationEventPublisher.
[SuppressMessage("Naming", "CA1711:Identifiers should not have incorrect suffix", Justification = "Integration event handler is a messaging term of art and is unrelated to System.EventHandler.")]
public interface IIntegrationEventHandler<in TEvent> where TEvent : IIntegrationEvent
Type Parameters
TEventThe concrete integration event type. Dispatch matches the runtime type of the event exactly; base-type and interface-type handlers are not resolved automatically.
- Extension Methods
Remarks
This is the framework's default, in-process consumer for integration events: it lets a modular monolith react to its own published contracts without a message broker, and it makes integration events testable. When you move a consumer to a separate service, replace the default publisher with a broker adapter and the producing side is unchanged.
Like domain-event handlers, integration-event handlers are best-effort side effects: the default publisher logs and swallows non-cancellation exceptions so one handler's failure does not block the others. Handlers must be idempotent - the transactional outbox delivers at least once.
Methods
HandleAsync(TEvent, CancellationToken)
Handles the specified integration event.
ValueTask HandleAsync(TEvent integrationEvent, CancellationToken cancellationToken)
Parameters
integrationEventTEventThe integration event being delivered.
cancellationTokenCancellationTokenA token to observe while the handler runs.