Skip to content

Commit 970e3f0

Browse files
authored
Headers review
1 parent 362df23 commit 970e3f0

File tree

1 file changed

+62
-40
lines changed

1 file changed

+62
-40
lines changed

nservicebus/messaging/headers.md

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,28 @@ The headers of a message are similar to HTTP headers and contain metadata about
1919

2020
For all timestamp message headers, the format is `yyyy-MM-dd HH:mm:ss:ffffff Z` where the time is UTC. The helper class `DateTimeExtensions` supports converting from UTC to wire format and vice versa by using the `ToWireFormattedString()` and `ToUtcDateTime()` methods.
2121

22+
### ISO 8601 format
23+
24+
This is NOT the [ISO 8601 format](https://nl.wikipedia.org/wiki/ISO_8601) but a custom format.
25+
26+
Differences:
27+
28+
1. a `T` between date and time
29+
2. uses a `.` between seconds and milli/microseconds
30+
3. no space between the timestamp and the `Z`
31+
32+
33+
```
34+
ISO 8601: yyyy-MM-ddTHH:mm:ss.ffffffZ
35+
NServiceBus: yyyy-MM-dd HH:mm:ss:ffffff Z
36+
```
37+
38+
When doing native intergration and there is a need to parse the timestamp the `.` as second and milli/microsecond separator is where regular timestamp parsers often fail.
39+
40+
Use the following code to generate or read our custom timestamp format.
41+
2242
```cs
23-
const string Format = "yyyy-MM-dd HH:mm:ss:ffffff Z";
43+
const string Format = "yyyy-MM-dd HH:mm:ss:ffffff Z"; // Not ISO 8601
2444
2545
public static string ToWireFormattedString(DateTime dateTime)
2646
{
@@ -47,15 +67,19 @@ The `TimeToBeReceived` header [controls when a message becomes obsolete and can
4767

4868
### NServiceBus.Transport.Encoding
4969

50-
States what type of body serialization is used. Used only by the legacy Azure Service Bus transport which is no longer supported.
70+
States what type of body serialization is used.
71+
72+
Used only by the legacy Azure Service Bus transport (`NServiceBus.Azure.Transports.WindowsAzureServiceBus` package) which is no longer supported.
5173

5274
## Serialization headers
5375

5476
The following headers include information for the receiving endpoint on the [message serialization](/nservicebus/serialization/) option that was used.
5577

5678
### NServiceBus.ContentType
5779

58-
The type of serialization used for the message, for example `text/xml`, `text/json`, `application/json`, or `application/json; systemjson`. In some cases, it may be useful to use the `NServiceBus.Version` header to determine how to use the value in this header appropriately.
80+
The type of serialization used for the message, for example `text/xml`, `text/json`, `application/json`, or `application/json; systemjson`.
81+
82+
In some cases, it may be useful to use the `NServiceBus.Version` header to determine how to use the value in this header appropriately.
5983

6084
> [!WARNING]
6185
> Although this header mimicks the [HTTP Content-Type header](https://www.rfc-editor.org/rfc/rfc9110.html#name-content-type) the values are case-sensitive. The header value does not behave like HTTP headers where everything after `;` is used to order and match the best qualified (application/json) serializer. Adding a suffix like `; systemjson` requires **all** endpoints involved to use this full key (for example: `application/json; systemjson`).
@@ -64,8 +88,8 @@ The type of serialization used for the message, for example `text/xml`, `text/js
6488

6589
The fully qualified .NET type name of the enclosed message(s). The receiving endpoint will use this type when deserializing an incoming message. Depending on the [versioning strategy](/samples/versioning/) the type can be specified in the following ways:
6690

67-
* Full type name: `Namespace.ClassName`.
68-
* Assembly qualified name: `Namespace.ClassName, AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null`.
91+
* Full type name: `Namespace.ClassName`.
92+
* Assembly qualified name: `Namespace.ClassName, AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null`.
6993

7094
See the [message type detection documentation](/nservicebus/messaging/message-type-detection.md) for more details.
7195

@@ -107,10 +131,9 @@ partial: conversationid
107131

108132
> [!WARNING]
109133
> Attempting to override an existing Conversation ID is not supported and will produce the following error:
110-
111-
```
112-
Cannot set the NServiceBus.ConversationId header to 'XXXXX' as it cannot override the incoming header value ('2f4076a0-d8de-4297-9d18-a830015dd42a').
113-
```
134+
> ```
135+
> Cannot set the NServiceBus.ConversationId header to 'XXXXX' as it cannot override the incoming header value ('2f4076a0-d8de-4297-9d18-a830015dd42a').
136+
> ```
114137
115138
> [!NOTE]
116139
> `Conversation Id` is very similar to `Correlation Id`. Both headers are copied to each new message that an endpoint produces. Whereas `Conversation Id` is always copied from the incoming message being handled, `Correlation Id` can come from another source (such as when replying from a saga using `ReplyToOriginator(...)`).
@@ -130,13 +153,13 @@ The `MessageId` that caused the current message to be sent. Whenever a message i
130153
131154
Message intent can have one of the following values:
132155
133-
| Value | Description |
134-
| ------------- |-------------|
135-
| Send |Regular point-to-point send. Note that messages sent to the error queue will also have a `Send` intent|
136-
| Publish |The message is an event that has been published and will be sent to all subscribers.|
137-
| Subscribe |A [control message](#messaging-interaction-headers-nservicebus-messageintent) indicating that the source endpoint would like to subscribe to a specific message.|
138-
| Unsubscribe |A [control message](#messaging-interaction-headers-nservicebus-messageintent) indicating that the source endpoint would like to unsubscribe to a specific message.|
139-
| Reply | The message has been initiated by doing a Reply or a Return from within a Handler or a Saga. |
156+
| Value | Description |
157+
|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
158+
| Send | Regular point-to-point send. Note that messages sent to the error queue will also have a `Send` intent |
159+
| Publish | The message is an event that has been published and will be sent to all subscribers. |
160+
| Subscribe | A [control message](#messaging-interaction-headers-nservicebus-messageintent) indicating that the source endpoint would like to subscribe to a specific message. |
161+
| Unsubscribe | A [control message](#messaging-interaction-headers-nservicebus-messageintent) indicating that the source endpoint would like to unsubscribe to a specific message. |
162+
| Reply | The message has been initiated by doing a Reply or a Return from within a Handler or a Saga. |
140163
141164
### NServiceBus.ControlMessage
142165
@@ -160,10 +183,10 @@ In the above example, headers are for a Send and hence the `MessageIntent` heade
160183
161184
When replying to a message:
162185
163-
* The `MessageIntent` is `Reply`.
164-
* The `RelatedTo` will be the same as the initiating `MessageID`.
165-
* The `ConversationId` will be the same as the initiating `ConversationId`.
166-
* The `CorrelationId` will be the same as the initiating `CorrelationId`.
186+
* The `MessageIntent` is `Reply`.
187+
* The `RelatedTo` will be the same as the initiating `MessageID`.
188+
* The `ConversationId` will be the same as the initiating `ConversationId`.
189+
* The `CorrelationId` will be the same as the initiating `CorrelationId`.
167190
168191
169192
### Example reply headers
@@ -188,8 +211,8 @@ snippet: HeaderWriterPublish
188211
189212
When returning a message instead of replying:
190213
191-
* The Return has the same points as the Reply example above with some additions.
192-
* The `ReturnMessage.ErrorCode` contains the value that was supplied to the `Bus.Return` method.
214+
* The Return has the same points as the Reply example above with some additions.
215+
* The `ReturnMessage.ErrorCode` contains the value that was supplied to the `Bus.Return` method.
193216
194217
195218
### Example return headers
@@ -230,8 +253,8 @@ A header to indicate that this message resulted from a Defer.
230253
231254
When a message is dispatched from within a saga the message will contain the following:
232255
233-
* An `OriginatingSagaId` header which matches the ID used as the index for the saga data stored in persistence.
234-
* An `OriginatingSagaType` which is the fully qualified type name of the saga that sent the message.
256+
* An `OriginatingSagaId` header which matches the ID used as the index for the saga data stored in persistence.
257+
* An `OriginatingSagaType` which is the fully qualified type name of the saga that sent the message.
235258
236259
237260
### Example "send from saga" headers
@@ -243,9 +266,9 @@ snippet: HeaderWriterSagaSending
243266
244267
A message reply is performed from a saga will have the following headers:
245268
246-
* The send headers are the same as a normal reply headers with a few additions.
247-
* Since this reply is from a secondary saga then `OriginatingSagaId` and `OriginatingSagaType` will match the second saga.
248-
* Since this is a reply to the initial saga then the headers will contain `SagaId` and `SagaType` headers that match the initial saga.
269+
* The send headers are the same as a normal reply headers with a few additions.
270+
* Since this reply is from a secondary saga then `OriginatingSagaId` and `OriginatingSagaType` will match the second saga.
271+
* Since this is a reply to the initial saga then the headers will contain `SagaId` and `SagaType` headers that match the initial saga.
249272
250273
251274
### Example "replying to a saga" headers
@@ -265,9 +288,9 @@ snippet: HeaderWriterSagaReplyingToOriginator
265288
266289
When requesting a timeout from a saga:
267290
268-
* The `OriginatingSagaId`, `OriginatingSagaType`, `SagaId` and `SagaType` will all match the Saga that requested the Timeout.
269-
* The `Timeout.RouteExpiredTimeoutTo` header contains the queue name for where the callback for the timeout should be sent.
270-
* The `Timeout.Expire` header contains the timestamp for when the timeout should fire.
291+
* The `OriginatingSagaId`, `OriginatingSagaType`, `SagaId` and `SagaType` will all match the Saga that requested the Timeout.
292+
* The `Timeout.RouteExpiredTimeoutTo` header contains the queue name for where the callback for the timeout should be sent.
293+
* The `Timeout.Expire` header contains the timestamp for when the timeout should fire.
271294
272295
273296
#### Example timeout headers
@@ -293,9 +316,9 @@ Headers used to give visibility into "where", "when" and "by whom" of a message.
293316
294317
The [host details](/nservicebus/hosting/override-hostid.md) of the endpoint where the message was being processed. This header contains three parts:
295318
296-
* `$.diagnostics.hostdisplayname`
297-
* `$.diagnostics.hostid`
298-
* `$.diagnostics.originating.hostid`
319+
* `$.diagnostics.hostdisplayname`
320+
* `$.diagnostics.hostid`
321+
* `$.diagnostics.originating.hostid`
299322
300323
### NServiceBus.TimeSent
301324
@@ -324,13 +347,13 @@ The NServiceBus version number.
324347
325348
These headers are added when [OpenTelemetry](/nservicebus/operations/opentelemetry.md) is enabled for an endpoint, in accordance with the [W3C Trace Context specification](https://www.w3.org/TR/trace-context):
326349
327-
- [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
328-
- [`tracestate`](https://www.w3.org/TR/trace-context/#tracestate-header)
329-
- [`baggage`](https://www.w3.org/TR/baggage/#baggage-http-header-format)
350+
* [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header)
351+
* [`tracestate`](https://www.w3.org/TR/trace-context/#tracestate-header)
352+
* [`baggage`](https://www.w3.org/TR/baggage/#baggage-http-header-format)
330353
331354
## Audit headers
332355
333-
Headers added when a message is [audited](/nservicebus/operations/auditing.md)
356+
Headers added when a message is [audited](/nservicebus/operations/auditing.md).
334357
335358
### NServiceBus.ProcessingEnded
336359
@@ -518,7 +541,6 @@ Part of the control message send back to ServiceControl to signal that a message
518541
519542
Contains the [NServiceBus.MessageId](#messaging-interaction-headers-nservicebus-messageid) value of the message that was succesfully processed.
520543
521-
Part of the control message send back to
522-
544+
Part of the control message send back to ServiceControl to signal that a message that was manually retried in ServicePulse/Control and flag as processed succesful.
523545
524-
The presence of any header key that starts with `ServiceControl.` would indicate its a message that is manually retried.
546+
The presence of any header key that starts with `ServiceControl.` would indicate its a message that is manually retried.

0 commit comments

Comments
 (0)