LiteBus
CatalogTransport

Canonical Wire Headers

  • ID: transport.canonical-headers
  • Name: Canonical wire headers
  • Maturity: GA
  • Summary: Stable header name contract and typed value readers used across AMQP, Kafka, SQS, Azure Service Bus, and in-memory adapters.

What It Does

TransportHeaders defines the canonical header names that dispatch writes and ingress reads. TransportHeaderValues provides broker-tolerant value coercion for string and integer reads, including UTF-8 byte arrays and numeric conversions.

Canonical headers are transport contract surface. Renaming them breaks wire compatibility.

Public Surface

TypeMemberRole
TransportHeadersHeader constantsCanonical wire names
TransportHeaderValuesGetString(headers, name)Typed string read
TransportHeaderValuesGetInt32(headers, name)Typed integer read
TransportHeaderValuesConvertToString(value)Broker-safe value conversion
TransportHeaderMappingExceptionexception typeMissing required header guard

Full Canonical Header Table

ConstantHeader nameType on wireRead rule
MessageIdlitebus-message-idstringRequired for durable identity when present
ContractNamelitebus-contract-namestringRequired for ingress contract resolution
ContractVersionlitebus-contract-versionnumber or stringParsed by GetInt32
CorrelationIdcorrelation-idstringPreferred correlation header
CausationIdcausation-idstringUpstream causal message id
TenantIdtenant-idstringTenant partition metadata
TraceContextlitebus-trace-contextstringDistributed trace context payload
IdempotencyKeylitebus-idempotency-keystringDurable idempotency key
VisibleAfterlitebus-visible-afterISO-8601 stringAbsolute visibility timestamp
VisibleAfterDelaylitebus-visible-after-delaynumber or stringRelative visibility delay seconds
ContentEncodinglitebus-content-encodingstringPayload encoding marker (base64 for SQS binary path)
LegacyCorrelationIdCorrelationIdstringLegacy ingress fallback only

Conversion Rules (TransportHeaderValues)

Input valueGetStringGetInt32
stringreturned as-isparsed with invariant culture
byte[]UTF-8 decodeparsed when length is 1 or 4
ReadOnlyMemory<byte> / Memory<byte>UTF-8 decodenot used directly for int parsing
int, byte, sbyte, shortinvariant conversionconverted directly
longinvariant conversionaccepted when in Int32 range
other valuesinvariant Convert.ToStringrejected (null)

Packages

  • LiteBus.Transport.Abstractions
  • Alias compatibility in LiteBus.Transport.Amqp via AmqpHeaders and AmqpHeaderValues

Requires

  • None

Invariants

  • Header names are public wire contract and must remain stable.
  • Legacy CorrelationId is read fallback only, not default write target.
  • Header readers apply invariant culture and broker-safe coercion.

Non-Goals

  • Payload serialization format selection.
  • Header encryption and signing.
  • Broker-specific metadata namespaces beyond canonical mapping.

Observability

  • litebus-trace-context is the transport header used for trace propagation payload.
  • Send and process spans use mapped message and correlation identifiers.

Test Coverage

Covered

Test methodProject
CanonicalHeaders_ShouldUseStableWireNamesLiteBus.Transport.UnitTests
GetString_ShouldReadByteEncodedHeadersLiteBus.Transport.UnitTests
GetString_ShouldConvertSupportedHeaderValueTypesLiteBus.Transport.IntegrationTests (Amqp/)
GetInt32_ShouldParseNumericHeaderVariantsLiteBus.Transport.IntegrationTests (Amqp/)
ToSendMessageRequest_WithBinaryBody_ShouldBase64EncodeLiteBus.Transport.UnitTests (AwsSqs/)
ToTransportMessage_WithBase64Body_ShouldDecodeBytesLiteBus.Transport.UnitTests (AwsSqs/)
MissingContractName_ShouldDiscardWithoutStoreWriteLiteBus.Durable.IntegrationTests (Ingress/InMemory/, Ingress/AwsSqs/)

Untested

  • End-to-end LegacyCorrelationId fallback path on each broker.
  • Explicit round-trip checks for VisibleAfter and VisibleAfterDelay on all adapters.

Out-of-Scope

  • Custom encryption and signed header envelopes.
  • Non-canonical broker metadata key spaces.

Deep Docs

On this page