Table of Contents

Interface IMessageMetadataBuilder

Namespace
Excalibur.Dispatch
Assembly
Excalibur.Dispatch.Abstractions.dll

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, AddRole
  • MetadataBuilderVersioningExtensions -- WithContentEncoding, WithMessageVersion, WithSerializerVersion, WithContractVersion
  • MetadataBuilderRoutingExtensions -- WithSource, WithDestination, WithReplyTo, WithSessionId, WithPartitionKey, WithRoutingKey, WithGroupId, WithGroupSequence, WithMessageType, WithContentType
  • MetadataBuilderTemporalExtensions -- WithCreatedTimestampUtc, WithSentTimestampUtc, WithReceivedTimestampUtc, WithScheduledEnqueueTimeUtc, WithTimeToLive, WithExpiresAtUtc, WithTiming
  • MetadataBuilderTransportExtensions -- WithDeliveryCount, WithMaxDeliveryCount, WithLastDeliveryError, WithDeadLetter*, WithPriority, WithDurable, WithDuplicateDetection
  • MetadataBuilderEventSourcingExtensions -- WithEventSourcing, WithGlobalPosition, WithEventType, WithEventVersion
  • MetadataBuilderCollectionExtensions -- 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

key string

The header key.

value string

The header value.

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

causationId string

The 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

correlationId string

The 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

messageId string

The 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

key string

The property key.

value object

The property value, or null to remove.

Returns

IMessageMetadataBuilder

The builder instance for method chaining.