Table of Contents

Class MiddlewareContext

Namespace
CarrotMQ.Core.MessageProcessing.Middleware
Assembly
CarrotMQ.Core.dll

Gives the ICarrotMiddleware the ability to control to read and change the handler input and the response.

public class MiddlewareContext
Inheritance
MiddlewareContext
Inherited Members

Constructors

MiddlewareContext(CarrotMessage, Type, ConsumerContext, CancellationToken)

Creates a new middleware context

public MiddlewareContext(CarrotMessage message, Type messageType, ConsumerContext consumerContext, CancellationToken cancellationToken)

Parameters

message CarrotMessage
messageType Type
consumerContext ConsumerContext
cancellationToken CancellationToken

Properties

CancellationToken

Provides cancellation support for the current processing pipeline

public CancellationToken CancellationToken { get; }

Property Value

CancellationToken

ConsumerContext

The ConsumerContext of the current request

public ConsumerContext ConsumerContext { get; }

Property Value

ConsumerContext

DeliveryStatus

The DeliveryStatus. Can be overwritten by the middleware to discard, ack or retry the message.

public DeliveryStatus DeliveryStatus { get; set; }

Property Value

DeliveryStatus

HandlerResult

The handler result, if the message is a request.

public IHandlerResult? HandlerResult { get; set; }

Property Value

IHandlerResult

HandlerType

The type of the message handler, if one is registered

public Type? HandlerType { get; }

Property Value

Type

IsErrorResult

Signals whether the response contains an error description. If the handler or middleware throws an unhandled exception and this property is still false, the framework will provide a default error response

public bool IsErrorResult { get; set; }

Property Value

bool

Message

The message being processed

public CarrotMessage Message { get; }

Property Value

CarrotMessage

MessageType

The type of the received message

public Type MessageType { get; }

Property Value

Type

ResponseRequired

Signals whether a response is required to be sent.

public bool ResponseRequired { get; set; }

Property Value

bool

ResponseSent

Signals whether a response has already been sent.

public bool ResponseSent { get; set; }

Property Value

bool

Remarks

This flag can be used in ICarrotMiddleware if message sending is handled there.