Skip to content

Why Foreign is read-only, and the envelope wins

An event has eight attributes and extensions. A message carries more: a broker's headers, a conversation id, the machine that sent it. The design had to say where that goes. The options left after ruling out renaming were to drop it and count it, or to keep it. go/envelope keeps it, in Foreign, and never sends it.

Read-only

A Foreign is for the reader. If a format wrote it back, a reply would carry the headers of the request it answers, and a forwarded message would carry the previous hop's broker ids. Dropping them on the way out keeps each hop's metadata its own. A caller who needs a header to travel copies it into an extension, on purpose.

Why not rename

Renaming foreign headers to fit the event's naming rules loses information. The design record measured Correlation-Id and CorrelationId both becoming correlationid, with the survivor decided by map iteration order. A key kept as it arrived cannot collide that way.

The envelope wins

Some envelopes have a field that a transport header can also carry, such as MassTransit's messageId and the transport's MessageId. When both exist and differ, one has to be the event.

The envelope's value is. It is the producer's statement about its own message, and the event's identity is derived from it. The transport's value is kept in Foreign.Headers under its own key, and the key is listed in Foreign.Conflicts, so the disagreement is visible rather than resolved silently. Only the interop formats can produce a conflict. A transport header that only repeats what the envelope says is not a conflict, and is not listed.

The design is go/messaging spec 0014, D10 and OQ3.