Table of Contents

Class MessageMetadataBuilder

Namespace
Excalibur.Dispatch.Metadata
Assembly
Excalibur.Dispatch.dll

Builder for creating and modifying unified message metadata instances.

public sealed class MessageMetadataBuilder : IMessageMetadataBuilder
Inheritance
MessageMetadataBuilder
Implements
Inherited Members
Extension Methods

Properties

MarkerType

Gets an optional marker type for tooling.

public Type? MarkerType { get; }

Property Value

Type

The optional marker type for tooling.

Methods

AddAttribute(string, object)

Adds an attribute to the message metadata.

public IMessageMetadataBuilder AddAttribute(string key, object value)

Parameters

key string
value object

Returns

IMessageMetadataBuilder

AddAttributes(IEnumerable<KeyValuePair<string, object>>)

Adds multiple attributes to the message metadata.

public IMessageMetadataBuilder AddAttributes(IEnumerable<KeyValuePair<string, object>> attributes)

Parameters

attributes IEnumerable<KeyValuePair<string, object>>

Returns

IMessageMetadataBuilder

AddClaim(Claim)

Adds a security claim to the message metadata.

public IMessageMetadataBuilder AddClaim(Claim claim)

Parameters

claim Claim

Returns

IMessageMetadataBuilder

AddHeader(string, string)

Adds a single header to the message metadata.

public IMessageMetadataBuilder AddHeader(string key, string value)

Parameters

key string

The header key.

value string

The header value.

Returns

IMessageMetadataBuilder

The builder instance for method chaining.

AddHeaders(IEnumerable<KeyValuePair<string, string>>)

Adds multiple headers to the message metadata.

public IMessageMetadataBuilder AddHeaders(IEnumerable<KeyValuePair<string, string>> headers)

Parameters

headers IEnumerable<KeyValuePair<string, string>>

Returns

IMessageMetadataBuilder

AddItem(string, object)

Adds an item to the message metadata.

public IMessageMetadataBuilder AddItem(string key, object value)

Parameters

key string
value object

Returns

IMessageMetadataBuilder

AddItems(IEnumerable<KeyValuePair<string, object>>)

Adds multiple items to the message metadata.

public IMessageMetadataBuilder AddItems(IEnumerable<KeyValuePair<string, object>> items)

Parameters

items IEnumerable<KeyValuePair<string, object>>

Returns

IMessageMetadataBuilder

AddProperties(IEnumerable<KeyValuePair<string, object>>)

Adds multiple properties to the message metadata.

public IMessageMetadataBuilder AddProperties(IEnumerable<KeyValuePair<string, object>> properties)

Parameters

properties IEnumerable<KeyValuePair<string, object>>

Returns

IMessageMetadataBuilder

AddProperty(string, object)

Adds a property to the message metadata.

public IMessageMetadataBuilder AddProperty(string key, object value)

Parameters

key string
value object

Returns

IMessageMetadataBuilder

AddRole(string)

Adds a role to the message metadata.

public IMessageMetadataBuilder AddRole(string role)

Parameters

role string

Returns

IMessageMetadataBuilder

Build()

Builds the immutable message metadata instance from the configured values.

public IMessageMetadata Build()

Returns

IMessageMetadata

An immutable IMessageMetadata instance.

WithBaggage(string?)

Sets the baggage information for distributed tracing.

public IMessageMetadataBuilder WithBaggage(string? baggage)

Parameters

baggage string

Returns

IMessageMetadataBuilder

WithCausationId(string?)

Sets the causation identifier linking this message to its immediate cause.

public IMessageMetadataBuilder WithCausationId(string? causationId)

Parameters

causationId string

The identifier of the message that caused this message.

Returns

IMessageMetadataBuilder

The builder instance for method chaining.

WithClaims(IEnumerable<Claim>?)

Sets the security claims associated with the message.

public IMessageMetadataBuilder WithClaims(IEnumerable<Claim>? claims)

Parameters

claims IEnumerable<Claim>

Returns

IMessageMetadataBuilder

WithContentEncoding(string?)

Sets the content encoding of the message.

public IMessageMetadataBuilder WithContentEncoding(string? contentEncoding)

Parameters

contentEncoding string

Returns

IMessageMetadataBuilder

WithContentType(string)

Sets the content type of the message.

public IMessageMetadataBuilder WithContentType(string contentType)

Parameters

contentType string

Returns

IMessageMetadataBuilder

WithContractVersion(string?)

Sets the contract version for message compatibility.

public IMessageMetadataBuilder WithContractVersion(string? contractVersion)

Parameters

contractVersion string

Returns

IMessageMetadataBuilder

WithCorrelationId(string)

Sets the correlation identifier for message tracing.

public IMessageMetadataBuilder WithCorrelationId(string correlationId)

Parameters

correlationId string

The correlation identifier to track related messages.

Returns

IMessageMetadataBuilder

The builder instance for method chaining.

WithCreatedTimestampUtc(DateTimeOffset)

Sets the UTC timestamp when the message was created.

public IMessageMetadataBuilder WithCreatedTimestampUtc(DateTimeOffset createdTimestampUtc)

Parameters

createdTimestampUtc DateTimeOffset

Returns

IMessageMetadataBuilder

WithDeadLetterErrorDescription(string?)

Sets the detailed error description for dead letter messages.

public IMessageMetadataBuilder WithDeadLetterErrorDescription(string? deadLetterErrorDescription)

Parameters

deadLetterErrorDescription string

Returns

IMessageMetadataBuilder

WithDeadLetterQueue(string?)

Sets the name of the dead letter queue for failed messages.

public IMessageMetadataBuilder WithDeadLetterQueue(string? deadLetterQueue)

Parameters

deadLetterQueue string

Returns

IMessageMetadataBuilder

WithDeadLetterReason(string?)

Sets the reason why the message was sent to the dead letter queue.

public IMessageMetadataBuilder WithDeadLetterReason(string? deadLetterReason)

Parameters

deadLetterReason string

Returns

IMessageMetadataBuilder

WithDeliveryCount(int)

Sets the number of delivery attempts for the message.

public IMessageMetadataBuilder WithDeliveryCount(int deliveryCount)

Parameters

deliveryCount int

Returns

IMessageMetadataBuilder

Exceptions

ArgumentOutOfRangeException

Thrown when delivery count is negative.

WithDestination(string?)

Sets the destination for the message.

public IMessageMetadataBuilder WithDestination(string? destination)

Parameters

destination string

Returns

IMessageMetadataBuilder

WithDuplicateDetectionWindow(TimeSpan?)

Sets the time window for duplicate detection.

public IMessageMetadataBuilder WithDuplicateDetectionWindow(TimeSpan? duplicateDetectionWindow)

Parameters

duplicateDetectionWindow TimeSpan?

Returns

IMessageMetadataBuilder

Exceptions

ArgumentOutOfRangeException

Thrown when window is not positive.

WithDurable(bool?)

Sets whether the message is durable and should survive broker restarts.

public IMessageMetadataBuilder WithDurable(bool? durable)

Parameters

durable bool?

Returns

IMessageMetadataBuilder

WithEventSourcing(string?, string?, long?, string?, long?)

Sets event sourcing metadata for the message.

public IMessageMetadataBuilder WithEventSourcing(string? aggregateId = null, string? aggregateType = null, long? aggregateVersion = null, string? streamName = null, long? streamPosition = null)

Parameters

aggregateId string
aggregateType string
aggregateVersion long?
streamName string
streamPosition long?

Returns

IMessageMetadataBuilder

WithEventType(string)

Sets the type of the event for event sourcing.

public IMessageMetadataBuilder WithEventType(string eventType)

Parameters

eventType string

Returns

IMessageMetadataBuilder

WithEventVersion(int)

Sets the version of the event for event sourcing.

public IMessageMetadataBuilder WithEventVersion(int eventVersion)

Parameters

eventVersion int

Returns

IMessageMetadataBuilder

Exceptions

ArgumentOutOfRangeException

Thrown when version is negative.

WithExpiresAtUtc(DateTimeOffset?)

Sets the UTC timestamp when the message expires.

public IMessageMetadataBuilder WithExpiresAtUtc(DateTimeOffset? expiresAtUtc)

Parameters

expiresAtUtc DateTimeOffset?

Returns

IMessageMetadataBuilder

WithExternalId(string?)

Sets an external identifier for the message.

public IMessageMetadataBuilder WithExternalId(string? externalId)

Parameters

externalId string

Returns

IMessageMetadataBuilder

WithGlobalPosition(long)

Sets the global position in the event store.

public IMessageMetadataBuilder WithGlobalPosition(long globalPosition)

Parameters

globalPosition long

Returns

IMessageMetadataBuilder

Exceptions

ArgumentOutOfRangeException

Thrown when position is negative.

WithGroupId(string?)

Sets the group identifier for message grouping.

public IMessageMetadataBuilder WithGroupId(string? groupId)

Parameters

groupId string

Returns

IMessageMetadataBuilder

WithGroupSequence(long?)

Sets the sequence number within the message group.

public IMessageMetadataBuilder WithGroupSequence(long? groupSequence)

Parameters

groupSequence long?

Returns

IMessageMetadataBuilder

WithLastDeliveryError(string?)

Sets the error message from the last delivery attempt.

public IMessageMetadataBuilder WithLastDeliveryError(string? lastDeliveryError)

Parameters

lastDeliveryError string

Returns

IMessageMetadataBuilder

WithMaxDeliveryCount(int?)

Sets the maximum number of delivery attempts allowed.

public IMessageMetadataBuilder WithMaxDeliveryCount(int? maxDeliveryCount)

Parameters

maxDeliveryCount int?

Returns

IMessageMetadataBuilder

Exceptions

ArgumentOutOfRangeException

Thrown when max delivery count is not positive.

WithMessageId(string)

Sets the message identifier and optionally the correlation identifier if not already set.

public IMessageMetadataBuilder WithMessageId(string messageId)

Parameters

messageId string

The unique message identifier.

Returns

IMessageMetadataBuilder

The builder instance for method chaining.

WithMessageType(string)

Sets the message type identifier.

public IMessageMetadataBuilder WithMessageType(string messageType)

Parameters

messageType string

Returns

IMessageMetadataBuilder

WithMessageVersion(string?)

Sets the message format version.

public IMessageMetadataBuilder WithMessageVersion(string? messageVersion)

Parameters

messageVersion string

Returns

IMessageMetadataBuilder

WithPartitionKey(string?)

Sets the partition key for message distribution.

public IMessageMetadataBuilder WithPartitionKey(string? partitionKey)

Parameters

partitionKey string

Returns

IMessageMetadataBuilder

WithPriority(int?)

Sets the priority level of the message.

public IMessageMetadataBuilder WithPriority(int? priority)

Parameters

priority int?

Returns

IMessageMetadataBuilder

Exceptions

ArgumentOutOfRangeException

Thrown when priority is negative.

WithProperty(string, object?)

Sets a named property on the metadata builder. Well-known property keys from MetadataPropertyKeys are dispatched to typed internal fields by the concrete builder; unknown keys are stored in the general-purpose properties dictionary.

public IMessageMetadataBuilder WithProperty(string key, object? value)

Parameters

key string

The property key.

value object

The property value, or null to remove.

Returns

IMessageMetadataBuilder

The builder instance for method chaining.

WithReceivedTimestampUtc(DateTimeOffset)

Sets the UTC timestamp when the message was received (non-nullable overload).

public IMessageMetadataBuilder WithReceivedTimestampUtc(DateTimeOffset receivedTimestampUtc)

Parameters

receivedTimestampUtc DateTimeOffset

Returns

IMessageMetadataBuilder

WithReceivedTimestampUtc(DateTimeOffset?)

Sets the UTC timestamp when the message was received.

public IMessageMetadataBuilder WithReceivedTimestampUtc(DateTimeOffset? receivedTimestampUtc)

Parameters

receivedTimestampUtc DateTimeOffset?

Returns

IMessageMetadataBuilder

WithReplyTo(string?)

Sets the reply-to address for the message.

public IMessageMetadataBuilder WithReplyTo(string? replyTo)

Parameters

replyTo string

Returns

IMessageMetadataBuilder

WithRequiresDuplicateDetection(bool?)

Sets whether the message requires duplicate detection.

public IMessageMetadataBuilder WithRequiresDuplicateDetection(bool? requiresDuplicateDetection)

Parameters

requiresDuplicateDetection bool?

Returns

IMessageMetadataBuilder

WithRoles(IEnumerable<string>?)

Sets the roles associated with the message.

public IMessageMetadataBuilder WithRoles(IEnumerable<string>? roles)

Parameters

roles IEnumerable<string>

Returns

IMessageMetadataBuilder

WithRoutingKey(string?)

Sets the routing key for message routing.

public IMessageMetadataBuilder WithRoutingKey(string? routingKey)

Parameters

routingKey string

Returns

IMessageMetadataBuilder

WithScheduledEnqueueTimeUtc(DateTimeOffset?)

Sets the UTC timestamp when the message is scheduled to be enqueued.

public IMessageMetadataBuilder WithScheduledEnqueueTimeUtc(DateTimeOffset? scheduledEnqueueTimeUtc)

Parameters

scheduledEnqueueTimeUtc DateTimeOffset?

Returns

IMessageMetadataBuilder

WithSentTimestampUtc(DateTimeOffset)

Sets the UTC timestamp when the message was sent (non-nullable overload).

public IMessageMetadataBuilder WithSentTimestampUtc(DateTimeOffset sentTimestampUtc)

Parameters

sentTimestampUtc DateTimeOffset

Returns

IMessageMetadataBuilder

WithSentTimestampUtc(DateTimeOffset?)

Sets the UTC timestamp when the message was sent.

public IMessageMetadataBuilder WithSentTimestampUtc(DateTimeOffset? sentTimestampUtc)

Parameters

sentTimestampUtc DateTimeOffset?

Returns

IMessageMetadataBuilder

WithSerializerVersion(string?)

Sets the serializer version used for the message.

public IMessageMetadataBuilder WithSerializerVersion(string? serializerVersion)

Parameters

serializerVersion string

Returns

IMessageMetadataBuilder

WithSessionId(string?)

Sets the session identifier for the message.

public IMessageMetadataBuilder WithSessionId(string? sessionId)

Parameters

sessionId string

Returns

IMessageMetadataBuilder

WithSource(string?)

Sets the source of the message.

public IMessageMetadataBuilder WithSource(string? source)

Parameters

source string

Returns

IMessageMetadataBuilder

WithTenantId(string?)

Sets the tenant identifier for multi-tenant scenarios.

public IMessageMetadataBuilder WithTenantId(string? tenantId)

Parameters

tenantId string

Returns

IMessageMetadataBuilder

WithTimeToLive(TimeSpan?)

Sets the time-to-live duration for the message.

public IMessageMetadataBuilder WithTimeToLive(TimeSpan? timeToLive)

Parameters

timeToLive TimeSpan?

Returns

IMessageMetadataBuilder

WithTiming(DateTimeOffset?, DateTimeOffset?, DateTimeOffset?, TimeSpan?)

Sets timing-related metadata for the message.

public IMessageMetadataBuilder WithTiming(DateTimeOffset? createdUtc = null, DateTimeOffset? sentUtc = null, DateTimeOffset? scheduledUtc = null, TimeSpan? ttl = null)

Parameters

createdUtc DateTimeOffset?
sentUtc DateTimeOffset?
scheduledUtc DateTimeOffset?
ttl TimeSpan?

Returns

IMessageMetadataBuilder

WithTraceParent(string?)

Sets the trace parent identifier for distributed tracing.

public IMessageMetadataBuilder WithTraceParent(string? traceParent)

Parameters

traceParent string

Returns

IMessageMetadataBuilder

WithTraceState(string?)

Sets the trace state for distributed tracing.

public IMessageMetadataBuilder WithTraceState(string? traceState)

Parameters

traceState string

Returns

IMessageMetadataBuilder

WithUserId(string?)

Sets the user identifier associated with the message.

public IMessageMetadataBuilder WithUserId(string? userId)

Parameters

userId string

Returns

IMessageMetadataBuilder