Class HandlerBase<TMessage, TResponse>
Represents a base class for message handlers.
public abstract class HandlerBase<TMessage, TResponse> where TMessage : _IMessage<TMessage, TResponse> where TResponse : class
Type Parameters
TMessageThe type of the message being handled.
TResponseThe type of the response produced by the handler.
- Inheritance
-
HandlerBase<TMessage, TResponse>
- Derived
-
EventHandlerBase<TEvent>ResponseHandlerBase<TRequest, TResponse>
- Inherited Members
Remarks
You should never directly inherit from this class. Use EventHandlerBase<TEvent>, QueryHandlerBase<TQuery, TResponse>, ResponseHandlerBase<TRequest, TResponse> or CommandHandlerBase<TCommand, TResponse> instead
Constructors
HandlerBase()
protected HandlerBase()
Methods
HandleAsync(TMessage, ConsumerContext, CancellationToken)
Handles the incoming message and returns the result.
public abstract Task<IHandlerResult> HandleAsync(TMessage message, ConsumerContext consumerContext, CancellationToken cancellationToken)
Parameters
messageTMessageThe message to handle.
consumerContextConsumerContextThe consumer context.
cancellationTokenCancellationTokenThe cancellation token.
Returns
Reject()
Creates a handler result indicating that the event processing should be rejected.
public IHandlerResult Reject()
Returns
Remarks
If the queue is configured with a DeadLetter exchange, the message will be sent to that exchange
Retry()
Creates a handler result indicating that the event processing should be retried.
public IHandlerResult Retry()
Returns
Remarks
It is recommended to delay before returning a retry.