Table of Contents

Struct MessageEnvelopeStruct

Namespace
Excalibur.Dispatch.Messaging
Assembly
Excalibur.Dispatch.dll

High-performance struct for message envelope with minimal allocations.

[StructLayout(LayoutKind.Auto)]
public readonly struct MessageEnvelopeStruct : IEquatable<MessageEnvelopeStruct>
Implements
Inherited Members
Extension Methods

Remarks

Initializes a new instance of the MessageEnvelopeStruct struct.

Constructors

MessageEnvelopeStruct(string, ReadOnlyMemory<byte>, long, IReadOnlyDictionary<string, string>?, string?, string?, byte, int)

High-performance struct for message envelope with minimal allocations.

public MessageEnvelopeStruct(string messageId, ReadOnlyMemory<byte> body, long timestampTicks, IReadOnlyDictionary<string, string>? headers = null, string? correlationId = null, string? messageType = null, byte priority = 0, int timeToLiveSeconds = 0)

Parameters

messageId string
body ReadOnlyMemory<byte>
timestampTicks long
headers IReadOnlyDictionary<string, string>
correlationId string
messageType string
priority byte
timeToLiveSeconds int

Remarks

Initializes a new instance of the MessageEnvelopeStruct struct.

Properties

Body

Gets the message body as bytes.

public ReadOnlyMemory<byte> Body { get; }

Property Value

ReadOnlyMemory<byte>

The current Body value.

CorrelationId

Gets the correlation identifier.

public string? CorrelationId { get; }

Property Value

string

The current CorrelationId value.

Headers

Gets the message headers.

public IReadOnlyDictionary<string, string>? Headers { get; }

Property Value

IReadOnlyDictionary<string, string>

The current Headers value.

MessageId

Gets the message identifier.

public string MessageId { get; }

Property Value

string

The message identifier.

MessageType

Gets the message type.

public string? MessageType { get; }

Property Value

string

The current MessageType value.

Priority

Gets the message priority.

public byte Priority { get; }

Property Value

byte

The current Priority value.

TimeToLive

Gets the time to live as a TimeSpan.

public TimeSpan TimeToLive { get; }

Property Value

TimeSpan

The time to live as a TimeSpan.

TimeToLiveSeconds

Gets the time to live in seconds.

public int TimeToLiveSeconds { get; }

Property Value

int

The current TimeToLiveSeconds value.

Timestamp

Gets the timestamp as a DateTime.

public DateTime Timestamp { get; }

Property Value

DateTime

The timestamp as a DateTime.

TimestampTicks

Gets the timestamp in ticks.

public long TimestampTicks { get; }

Property Value

long

The current TimestampTicks value.

Methods

Equals(MessageEnvelopeStruct)

Determines whether the specified envelope is equal to the current envelope.

public bool Equals(MessageEnvelopeStruct other)

Parameters

other MessageEnvelopeStruct

Returns

bool

Equals(object?)

Determines whether the specified object is equal to the current envelope.

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

Returns the hash code for this envelope.

public override int GetHashCode()

Returns

int

ToString()

Returns a string representation of this envelope.

public override string ToString()

Returns

string

WithBody(ReadOnlyMemory<byte>)

Creates a new envelope with the specified body.

public MessageEnvelopeStruct WithBody(ReadOnlyMemory<byte> body)

Parameters

body ReadOnlyMemory<byte>

Returns

MessageEnvelopeStruct

WithCorrelationId(string)

Creates a new envelope with the specified correlation ID.

public MessageEnvelopeStruct WithCorrelationId(string correlationId)

Parameters

correlationId string

Returns

MessageEnvelopeStruct

WithMessageId(string)

Creates a new envelope with the specified message ID.

public MessageEnvelopeStruct WithMessageId(string messageId)

Parameters

messageId string

Returns

MessageEnvelopeStruct

WithMessageType(string)

Creates a new envelope with the specified message type.

public MessageEnvelopeStruct WithMessageType(string messageType)

Parameters

messageType string

Returns

MessageEnvelopeStruct

WithPriority(byte)

Creates a new envelope with the specified priority.

public MessageEnvelopeStruct WithPriority(byte priority)

Parameters

priority byte

Returns

MessageEnvelopeStruct

WithTimeToLive(TimeSpan)

Creates a new envelope with the specified time to live.

public MessageEnvelopeStruct WithTimeToLive(TimeSpan timeToLive)

Parameters

timeToLive TimeSpan

Returns

MessageEnvelopeStruct

Operators

operator ==(MessageEnvelopeStruct, MessageEnvelopeStruct)

Determines whether two envelopes are equal.

public static bool operator ==(MessageEnvelopeStruct left, MessageEnvelopeStruct right)

Parameters

left MessageEnvelopeStruct
right MessageEnvelopeStruct

Returns

bool

operator !=(MessageEnvelopeStruct, MessageEnvelopeStruct)

Determines whether two envelopes are not equal.

public static bool operator !=(MessageEnvelopeStruct left, MessageEnvelopeStruct right)

Parameters

left MessageEnvelopeStruct
right MessageEnvelopeStruct

Returns

bool