Table of Contents

Interface IIntegrationEventHandler<TEvent>

Namespace
Trellis.Mediator
Assembly
Trellis.Mediator.dll

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

TEvent

The 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

integrationEvent TEvent

The integration event being delivered.

cancellationToken CancellationToken

A token to observe while the handler runs.

Returns

ValueTask

A ValueTask that completes when the handler is done.