Class MessageMetadataBuilder
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
Returns
AddAttributes(IEnumerable<KeyValuePair<string, object>>)
Adds multiple attributes to the message metadata.
public IMessageMetadataBuilder AddAttributes(IEnumerable<KeyValuePair<string, object>> attributes)
Parameters
attributesIEnumerable<KeyValuePair<string, object>>
Returns
AddClaim(Claim)
Adds a security claim to the message metadata.
public IMessageMetadataBuilder AddClaim(Claim claim)
Parameters
claimClaim
Returns
AddHeader(string, string)
Adds a single header to the message metadata.
public IMessageMetadataBuilder AddHeader(string key, string value)
Parameters
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
headersIEnumerable<KeyValuePair<string, string>>
Returns
AddItem(string, object)
Adds an item to the message metadata.
public IMessageMetadataBuilder AddItem(string key, object value)
Parameters
Returns
AddItems(IEnumerable<KeyValuePair<string, object>>)
Adds multiple items to the message metadata.
public IMessageMetadataBuilder AddItems(IEnumerable<KeyValuePair<string, object>> items)
Parameters
itemsIEnumerable<KeyValuePair<string, object>>
Returns
AddProperties(IEnumerable<KeyValuePair<string, object>>)
Adds multiple properties to the message metadata.
public IMessageMetadataBuilder AddProperties(IEnumerable<KeyValuePair<string, object>> properties)
Parameters
propertiesIEnumerable<KeyValuePair<string, object>>
Returns
AddProperty(string, object)
Adds a property to the message metadata.
public IMessageMetadataBuilder AddProperty(string key, object value)
Parameters
Returns
AddRole(string)
Adds a role to the message metadata.
public IMessageMetadataBuilder AddRole(string role)
Parameters
rolestring
Returns
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
baggagestring
Returns
WithCausationId(string?)
Sets the causation identifier linking this message to its immediate cause.
public IMessageMetadataBuilder WithCausationId(string? causationId)
Parameters
causationIdstringThe 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
claimsIEnumerable<Claim>
Returns
WithContentEncoding(string?)
Sets the content encoding of the message.
public IMessageMetadataBuilder WithContentEncoding(string? contentEncoding)
Parameters
contentEncodingstring
Returns
WithContentType(string)
Sets the content type of the message.
public IMessageMetadataBuilder WithContentType(string contentType)
Parameters
contentTypestring
Returns
WithContractVersion(string?)
Sets the contract version for message compatibility.
public IMessageMetadataBuilder WithContractVersion(string? contractVersion)
Parameters
contractVersionstring
Returns
WithCorrelationId(string)
Sets the correlation identifier for message tracing.
public IMessageMetadataBuilder WithCorrelationId(string correlationId)
Parameters
correlationIdstringThe 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
createdTimestampUtcDateTimeOffset
Returns
WithDeadLetterErrorDescription(string?)
Sets the detailed error description for dead letter messages.
public IMessageMetadataBuilder WithDeadLetterErrorDescription(string? deadLetterErrorDescription)
Parameters
deadLetterErrorDescriptionstring
Returns
WithDeadLetterQueue(string?)
Sets the name of the dead letter queue for failed messages.
public IMessageMetadataBuilder WithDeadLetterQueue(string? deadLetterQueue)
Parameters
deadLetterQueuestring
Returns
WithDeadLetterReason(string?)
Sets the reason why the message was sent to the dead letter queue.
public IMessageMetadataBuilder WithDeadLetterReason(string? deadLetterReason)
Parameters
deadLetterReasonstring
Returns
WithDeliveryCount(int)
Sets the number of delivery attempts for the message.
public IMessageMetadataBuilder WithDeliveryCount(int deliveryCount)
Parameters
deliveryCountint
Returns
Exceptions
- ArgumentOutOfRangeException
Thrown when delivery count is negative.
WithDestination(string?)
Sets the destination for the message.
public IMessageMetadataBuilder WithDestination(string? destination)
Parameters
destinationstring
Returns
WithDuplicateDetectionWindow(TimeSpan?)
Sets the time window for duplicate detection.
public IMessageMetadataBuilder WithDuplicateDetectionWindow(TimeSpan? duplicateDetectionWindow)
Parameters
duplicateDetectionWindowTimeSpan?
Returns
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
durablebool?
Returns
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
aggregateIdstringaggregateTypestringaggregateVersionlong?streamNamestringstreamPositionlong?
Returns
WithEventType(string)
Sets the type of the event for event sourcing.
public IMessageMetadataBuilder WithEventType(string eventType)
Parameters
eventTypestring
Returns
WithEventVersion(int)
Sets the version of the event for event sourcing.
public IMessageMetadataBuilder WithEventVersion(int eventVersion)
Parameters
eventVersionint
Returns
Exceptions
- ArgumentOutOfRangeException
Thrown when version is negative.
WithExpiresAtUtc(DateTimeOffset?)
Sets the UTC timestamp when the message expires.
public IMessageMetadataBuilder WithExpiresAtUtc(DateTimeOffset? expiresAtUtc)
Parameters
expiresAtUtcDateTimeOffset?
Returns
WithExternalId(string?)
Sets an external identifier for the message.
public IMessageMetadataBuilder WithExternalId(string? externalId)
Parameters
externalIdstring
Returns
WithGlobalPosition(long)
Sets the global position in the event store.
public IMessageMetadataBuilder WithGlobalPosition(long globalPosition)
Parameters
globalPositionlong
Returns
Exceptions
- ArgumentOutOfRangeException
Thrown when position is negative.
WithGroupId(string?)
Sets the group identifier for message grouping.
public IMessageMetadataBuilder WithGroupId(string? groupId)
Parameters
groupIdstring
Returns
WithGroupSequence(long?)
Sets the sequence number within the message group.
public IMessageMetadataBuilder WithGroupSequence(long? groupSequence)
Parameters
groupSequencelong?
Returns
WithLastDeliveryError(string?)
Sets the error message from the last delivery attempt.
public IMessageMetadataBuilder WithLastDeliveryError(string? lastDeliveryError)
Parameters
lastDeliveryErrorstring
Returns
WithMaxDeliveryCount(int?)
Sets the maximum number of delivery attempts allowed.
public IMessageMetadataBuilder WithMaxDeliveryCount(int? maxDeliveryCount)
Parameters
maxDeliveryCountint?
Returns
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
messageIdstringThe unique message identifier.
Returns
- IMessageMetadataBuilder
The builder instance for method chaining.
WithMessageType(string)
Sets the message type identifier.
public IMessageMetadataBuilder WithMessageType(string messageType)
Parameters
messageTypestring
Returns
WithMessageVersion(string?)
Sets the message format version.
public IMessageMetadataBuilder WithMessageVersion(string? messageVersion)
Parameters
messageVersionstring
Returns
WithPartitionKey(string?)
Sets the partition key for message distribution.
public IMessageMetadataBuilder WithPartitionKey(string? partitionKey)
Parameters
partitionKeystring
Returns
WithPriority(int?)
Sets the priority level of the message.
public IMessageMetadataBuilder WithPriority(int? priority)
Parameters
priorityint?
Returns
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
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
receivedTimestampUtcDateTimeOffset
Returns
WithReceivedTimestampUtc(DateTimeOffset?)
Sets the UTC timestamp when the message was received.
public IMessageMetadataBuilder WithReceivedTimestampUtc(DateTimeOffset? receivedTimestampUtc)
Parameters
receivedTimestampUtcDateTimeOffset?
Returns
WithReplyTo(string?)
Sets the reply-to address for the message.
public IMessageMetadataBuilder WithReplyTo(string? replyTo)
Parameters
replyTostring
Returns
WithRequiresDuplicateDetection(bool?)
Sets whether the message requires duplicate detection.
public IMessageMetadataBuilder WithRequiresDuplicateDetection(bool? requiresDuplicateDetection)
Parameters
requiresDuplicateDetectionbool?
Returns
WithRoles(IEnumerable<string>?)
Sets the roles associated with the message.
public IMessageMetadataBuilder WithRoles(IEnumerable<string>? roles)
Parameters
rolesIEnumerable<string>
Returns
WithRoutingKey(string?)
Sets the routing key for message routing.
public IMessageMetadataBuilder WithRoutingKey(string? routingKey)
Parameters
routingKeystring
Returns
WithScheduledEnqueueTimeUtc(DateTimeOffset?)
Sets the UTC timestamp when the message is scheduled to be enqueued.
public IMessageMetadataBuilder WithScheduledEnqueueTimeUtc(DateTimeOffset? scheduledEnqueueTimeUtc)
Parameters
scheduledEnqueueTimeUtcDateTimeOffset?
Returns
WithSentTimestampUtc(DateTimeOffset)
Sets the UTC timestamp when the message was sent (non-nullable overload).
public IMessageMetadataBuilder WithSentTimestampUtc(DateTimeOffset sentTimestampUtc)
Parameters
sentTimestampUtcDateTimeOffset
Returns
WithSentTimestampUtc(DateTimeOffset?)
Sets the UTC timestamp when the message was sent.
public IMessageMetadataBuilder WithSentTimestampUtc(DateTimeOffset? sentTimestampUtc)
Parameters
sentTimestampUtcDateTimeOffset?
Returns
WithSerializerVersion(string?)
Sets the serializer version used for the message.
public IMessageMetadataBuilder WithSerializerVersion(string? serializerVersion)
Parameters
serializerVersionstring
Returns
WithSessionId(string?)
Sets the session identifier for the message.
public IMessageMetadataBuilder WithSessionId(string? sessionId)
Parameters
sessionIdstring
Returns
WithSource(string?)
Sets the source of the message.
public IMessageMetadataBuilder WithSource(string? source)
Parameters
sourcestring
Returns
WithTenantId(string?)
Sets the tenant identifier for multi-tenant scenarios.
public IMessageMetadataBuilder WithTenantId(string? tenantId)
Parameters
tenantIdstring
Returns
WithTimeToLive(TimeSpan?)
Sets the time-to-live duration for the message.
public IMessageMetadataBuilder WithTimeToLive(TimeSpan? timeToLive)
Parameters
timeToLiveTimeSpan?
Returns
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
createdUtcDateTimeOffset?sentUtcDateTimeOffset?scheduledUtcDateTimeOffset?ttlTimeSpan?
Returns
WithTraceParent(string?)
Sets the trace parent identifier for distributed tracing.
public IMessageMetadataBuilder WithTraceParent(string? traceParent)
Parameters
traceParentstring
Returns
WithTraceState(string?)
Sets the trace state for distributed tracing.
public IMessageMetadataBuilder WithTraceState(string? traceState)
Parameters
traceStatestring
Returns
WithUserId(string?)
Sets the user identifier associated with the message.
public IMessageMetadataBuilder WithUserId(string? userId)
Parameters
userIdstring