Table of Contents

Interface IActionHandler<TAction>

Namespace
Excalibur.Dispatch.Delivery
Assembly
Excalibur.Dispatch.Abstractions.dll

Defines a handler for an action with no return value. This is the recommended handler interface for commands.

public interface IActionHandler<in TAction> where TAction : IDispatchAction

Type Parameters

TAction

The type of action to handle.

Extension Methods

Remarks

Recommended for most use cases. The framework automatically wraps the completion in IMessageResult. Use exception throwing for failures; the exception mapping middleware converts exceptions to proper failure results.

Common use cases include:

  • Commands that modify system state
  • Fire-and-forget operations
  • Asynchronous tasks that report completion through events

Handlers are resolved from dependency injection and should be registered with appropriate lifetime (typically scoped or transient).

For advanced scenarios requiring direct control over IMessageResult (e.g., cache hits, custom result metadata), use IDispatchHandler<TMessage> instead.

Methods

HandleAsync(TAction, CancellationToken)

Handles the specified action asynchronously.

Task HandleAsync(TAction action, CancellationToken cancellationToken)

Parameters

action TAction

The action to handle.

cancellationToken CancellationToken

The cancellation token to observe.

Returns

Task

A task representing the asynchronous operation.

Remarks

Implementations should respect the cancellation token and handle exceptions appropriately. The framework ensures this method is called within the message processing pipeline with proper context.