Preserve transport receive properties through message dispatch#7662
Preserve transport receive properties through message dispatch#7662danielmarbach merged 24 commits intomasterfrom
Conversation
|
This would allow us to have the transports store and reuse receive properties natively without having to double store temporary headers. ServiceControl can simply "uplift" those into header storage and when returning to the queuing, turn them into dispatch properties again. That means they are available in the tooling and never lost on the wire plus the transports don't need to take extra care anymore to make sure they are not lost. They only need to take care of serializing and deserializing the properties. I checked, and it has no impact on the envelope unwrapper; plus, if needed, those properties should still be accessible from the context bag. |
We need to be careful in releasing this until we have proper support in ServiceControl; there is a chance of data loss if we start adopting it. |
@mauroservienti Can you explain this further. |
…perties and a way for the transport to preserve properties
…transport for demonstration purposes - LearningTransport now populates ReceiveProperties with FileCreatedAt - Declares DispatchPropertyNamesToPreserve for auto-propagation to audit/error - Dogfoods the new ReceiveProperties feature with real integration test - Fully backward compatible - no wire format changes
…d improve failure handling
…ssages other than copy of the messages
14c0ee9 to
b162bbd
Compare
…DispatchPropertyNamesToPreserve - ReceiveProperties now implements IReadOnlyDictionary<string, string> with static Empty singleton instead of inheriting Dictionary<string, string> - IncomingMessage gains ReceiveProperties property and 4-param ctor overload - MessageContext gains ReceiveProperties property, reordered ctor params (receiveProperties after body, context last) - ErrorContext gains receiveProperties overload, same param order convention - RoutingToDispatchConnector reads from IncomingMessage.ReceiveProperties instead of ContextBag - EnvelopeUnwrapper passes ReceiveProperties from MessageContext to IncomingMessage - Renamed DispatchPropertyNamesToPreserve to ReceivePropertyNamesToPreserve on TransportDefinition - LearningTransport and LearningTransportMessagePump updated accordingly
4cb13bb to
658e000
Compare
658e000 to
3835df7
Compare
…spatch properties
…parameter and simplify receive properties propagation logic
57ef333 to
ffaf6a1
Compare
|
During the review, I realized, given we want to preserve information from the |
|
@andreasohlund and I discussed that as a follow up it probably makes sense to no longer expose IncomingMessage on the ErrorContext and recoverability interfaces but expose the raw elements of IncomingMessage since the incoming message is something that the Core transport integration is concerned about (for example, the envelope unwrapper) and not the error context itself. It should be more aligned in how MessageContext currently exposes the raw properties. |
See #7741 |
Extension of:
This pull request adds support for carrying transport-native receive metadata through the NServiceBus receive pipeline and propagating it to outgoing dispatch operations when the incoming message is copied.
Some transports receive messages with native properties that are not headers but still need to be preserved when the message is forwarded, audited, moved to the error queue, or otherwise copied to another transport operation. A concrete example is AWS SQS FIFO metadata such as message group or deduplication information. Until now, there was no first-class way for transports to expose that metadata to the pipeline or for the core to safely carry it forward.
What changed
ReceivePropertiesas a read-only representation of transport-specific metadata received with a message.ReceivePropertiestoIncomingMessage, making received transport metadata part of the message being processed rather than a separate pipeline extension.MessageContextandErrorContextso receive properties can be supplied by transports and retained through normal processing and recoverability flows.DispatchPropertiesalways take precedence over propagated receive properties.ReceivePropertiesfor the received message.Behavior and precedence
Receive properties are now treated as the transport’s per-message preservation decision:
ReceiveProperties, it is eligible to be propagated when the incoming message is copied.IncomingMessage, which avoids accidental propagation to unrelated outgoing messages.Why this matters
This provides a transport-agnostic foundation for preserving native transport metadata without turning those values into NServiceBus headers or requiring each transport to implement custom forwarding behavior.
It enables advanced transport scenarios, such as preserving SQS FIFO-related metadata, while keeping the decision of what to preserve with the transport that received the message.