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
messageCarrotMessagemessageTypeTypeconsumerContextConsumerContextcancellationTokenCancellationToken
Properties
CancellationToken
Provides cancellation support for the current processing pipeline
public CancellationToken CancellationToken { get; }
Property Value
ConsumerContext
The ConsumerContext of the current request
public ConsumerContext ConsumerContext { get; }
Property Value
DeliveryStatus
The DeliveryStatus. Can be overwritten by the middleware to discard, ack or retry the message.
public DeliveryStatus DeliveryStatus { get; set; }
Property Value
HandlerResult
The handler result, if the message is a request.
public IHandlerResult? HandlerResult { get; set; }
Property Value
HandlerType
The type of the message handler, if one is registered
public Type? HandlerType { get; }
Property Value
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
Message
The message being processed
public CarrotMessage Message { get; }
Property Value
MessageType
The type of the received message
public Type MessageType { get; }
Property Value
ResponseRequired
Signals whether a response is required to be sent.
public bool ResponseRequired { get; set; }
Property Value
ResponseSent
Signals whether a response has already been sent.
public bool ResponseSent { get; set; }
Property Value
Remarks
This flag can be used in ICarrotMiddleware if message sending is handled there.