Interface IMessageMetadataBuilder
Builder interface for creating immutable message metadata instances. Provides a minimal fluent API for constructing message metadata with core envelope properties and extensibility via WithProperty(string, object?).
public interface IMessageMetadataBuilder
- Extension Methods
Remarks
This interface follows the Microsoft design guideline of keeping interfaces small (max 5 methods + properties bag).
Domain-specific builder methods (identity, routing, temporal, transport, event sourcing) are available as
extension methods in Excalibur.Dispatch:
MetadataBuilderIdentityExtensions-- WithExternalId, WithUserId, WithTenantId, WithTraceParent, WithTraceState, WithBaggage, WithRoles, WithClaims, AddRoleMetadataBuilderVersioningExtensions-- WithContentEncoding, WithMessageVersion, WithSerializerVersion, WithContractVersionMetadataBuilderRoutingExtensions-- WithSource, WithDestination, WithReplyTo, WithSessionId, WithPartitionKey, WithRoutingKey, WithGroupId, WithGroupSequence, WithMessageType, WithContentTypeMetadataBuilderTemporalExtensions-- WithCreatedTimestampUtc, WithSentTimestampUtc, WithReceivedTimestampUtc, WithScheduledEnqueueTimeUtc, WithTimeToLive, WithExpiresAtUtc, WithTimingMetadataBuilderTransportExtensions-- WithDeliveryCount, WithMaxDeliveryCount, WithLastDeliveryError, WithDeadLetter*, WithPriority, WithDurable, WithDuplicateDetectionMetadataBuilderEventSourcingExtensions-- WithEventSourcing, WithGlobalPosition, WithEventType, WithEventVersionMetadataBuilderCollectionExtensions-- AddHeaders, AddAttributes, AddProperties, AddItems
Properties
MarkerType
Gets an optional marker type for tooling.
Type? MarkerType { get; }
Property Value
- Type
The optional marker type for tooling.
Methods
AddHeader(string, string)
Adds a single header to the message metadata.
IMessageMetadataBuilder AddHeader(string key, string value)
Parameters
Returns
- IMessageMetadataBuilder
The builder instance for method chaining.
Build()
Builds the immutable message metadata instance from the configured values.
IMessageMetadata Build()
Returns
- IMessageMetadata
An immutable IMessageMetadata instance.
WithCausationId(string?)
Sets the causation identifier linking this message to its immediate cause.
IMessageMetadataBuilder WithCausationId(string? causationId)
Parameters
causationIdstringThe identifier of the message that caused this message.
Returns
- IMessageMetadataBuilder
The builder instance for method chaining.
WithCorrelationId(string)
Sets the correlation identifier for message tracing.
IMessageMetadataBuilder WithCorrelationId(string correlationId)
Parameters
correlationIdstringThe correlation identifier to track related messages.
Returns
- IMessageMetadataBuilder
The builder instance for method chaining.
WithMessageId(string)
Sets the message identifier and optionally the correlation identifier if not already set.
IMessageMetadataBuilder WithMessageId(string messageId)
Parameters
messageIdstringThe unique message identifier.
Returns
- IMessageMetadataBuilder
The builder instance for method chaining.
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.
IMessageMetadataBuilder WithProperty(string key, object? value)
Parameters
Returns
- IMessageMetadataBuilder
The builder instance for method chaining.