Default Headers
Silverback will add some headers to the produced messages. They may vary depending on the scenario. Here is the list of the default headers that may be sent.
The static classes DefaultMessageHeaders and KafkaMessageHeaders contain all default header names constants.
Default
| Header | Name |
|---|---|
| MessageType | x-message-type |
| FailedAttempts | x-failed-attempts |
| ChunkIndex | x-chunk-index |
| ChunksCount | x-chunk-count |
| IsLastChunk | x-chunk-last |
| TraceId | traceparent |
| TraceState | tracestate |
| TraceBaggage | tracebaggage |
| ContentType | content-type |
| EncryptionKeyId | x-encryption-key-id |
| FailureReason | x-failure-reason |
Kafka
| Header | Name |
|---|---|
| Timestamp | x-kafka-message-timestamp |
| SourceConsumerGroupId | x-source-consumer-group-id |
| SourceTopic | x-source-topic |
| SourcePartition | x-source-partition |
| SourceOffset | x-source-offset |
| SourceTimestamp | x-source-timestamp |
| FirstChunkOffset | x-chunk-first-offset |
MQTT
MQTT doesn't add any additional header to the produced messages. The constants in MqttMessageHeaders are used internally to map some envelope headers to the corresponding MQTT 5 properties (response topic and correlation data) and to set the dynamic destination topic.
Customizing Default Header Names
The default header names can be overridden using the WithCustomHeaderName configuration method.
services.AddSilverback()
.WithConnectionToMessageBroker(options => options.AddKafka())
.WithCustomHeaderName(DefaultMessageHeaders.ChunkIndex, "x-ch-idx")
.WithCustomHeaderName(DefaultMessageHeaders.ChunksCount, "x-ch-cnt")
.AddBrokerClientsConfigurator<MyClientsConfigurator>();