Table of Contents

Class HandlerBase<TMessage, TResponse>

Namespace
CarrotMQ.Core.Handlers
Assembly
CarrotMQ.Core.dll

Represents a base class for message handlers.

public abstract class HandlerBase<TMessage, TResponse> where TMessage : _IMessage<TMessage, TResponse> where TResponse : class

Type Parameters

TMessage

The type of the message being handled.

TResponse

The type of the response produced by the handler.

Inheritance
HandlerBase<TMessage, TResponse>
Derived
ResponseHandlerBase<TRequest, TResponse>
Inherited Members

Remarks

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

message TMessage

The message to handle.

consumerContext ConsumerContext

The consumer context.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IHandlerResult>

Reject()

Creates a handler result indicating that the event processing should be rejected.

public IHandlerResult Reject()

Returns

IHandlerResult

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

IHandlerResult

Remarks

It is recommended to delay before returning a retry.