Class MessageEnvelope<TMessage>
Generic message envelope for strongly-typed message handling.
public sealed class MessageEnvelope<TMessage> : IDisposable where TMessage : IDispatchMessage
Type Parameters
TMessageThe type of the message.
- Inheritance
-
MessageEnvelope<TMessage>
- Implements
- Inherited Members
- Extension Methods
Constructors
MessageEnvelope(TMessage, in MessageMetadata)
Initializes a new instance of the MessageEnvelope<TMessage> class.
public MessageEnvelope(TMessage message, in MessageMetadata metadata)
Parameters
messageTMessagemetadataMessageMetadata
MessageEnvelope(TMessage, in MessageMetadata, IMessageContext?)
Initializes a new instance of the MessageEnvelope<TMessage> class. Initializes a new instance with metadata and context.
public MessageEnvelope(TMessage message, in MessageMetadata metadata, IMessageContext? context)
Parameters
messageTMessagemetadataMessageMetadatacontextIMessageContext
Properties
AcknowledgeMessageAsync
Gets or sets the acknowledge callback.
public Func<Task>? AcknowledgeMessageAsync { get; set; }
Property Value
- Func<Task>
The current AcknowledgeMessageAsync value.
Context
Gets or sets the message context.
public IMessageContext? Context { get; set; }
Property Value
- IMessageContext
The current Context value.
CorrelationId
Gets the correlation ID.
public string? CorrelationId { get; }
Property Value
- string
The current CorrelationId value.
Headers
Gets the message headers.
public IDictionary<string, string> Headers { get; }
Property Value
- IDictionary<string, string>
The current Headers value.
Message
Gets the strongly-typed message.
public TMessage Message { get; }
Property Value
- TMessage
The current Message value.
MessageId
Gets the message ID.
public string MessageId { get; }
Property Value
Metadata
Gets the message metadata.
public MessageMetadata Metadata { get; }
Property Value
- MessageMetadata
The current Metadata value.
RejectMessageAsync
Gets or sets the reject callback.
public Func<string?, Task>? RejectMessageAsync { get; set; }
Property Value
- Func<string, Task>
The current RejectMessageAsync value.
RetryCount
Gets the retry count.
public int RetryCount { get; }
Property Value
- int
The current RetryCount value.
Timestamp
Gets the timestamp.
public DateTimeOffset Timestamp { get; }
Property Value
- DateTimeOffset
The current Timestamp value.
Methods
Dispose()
Releases resources held by the inner envelope.
public void Dispose()
WithMetadata(in MessageMetadata)
Creates a new envelope with updated metadata.
public MessageEnvelope<TMessage> WithMetadata(in MessageMetadata metadata)
Parameters
metadataMessageMetadata
Returns
- MessageEnvelope<TMessage>