Skip to content

Conversation

@danielmarbach
Copy link
Contributor

@danielmarbach danielmarbach commented Aug 22, 2025

As part of going through the code base I realized the driver natively support ReadOnlyMemory<T>. This means we no longer have to call ToArray(). Unfortunately the driver still does a ToArray under the covers but this might be resolved in future versions of the driver which would then make the new code more memory efficient.

The underlying representation remains the same. Example

Before

[{"MessageId": "8136fa26-5d31-43fe-9afb-b34100c5e778", "Options": [{"k": "Destination", "v": "ADuplicateMessageArrives.DownstreamEndpoint"}], "Body": new BinData(0, "eyJUZXJtaW5hdG9yIjpmYWxzZX0="), "Headers": [{"k": "NServiceBus.MessageId", "v": "8136fa26-5d31-43fe-9afb-b34100c5e778"}, {"k": "NServiceBus.MessageIntent", "v": "Send"}, {"k": "NServiceBus.RelatedTo", "v": "57670dea-7904-4a0f-b92e-2f66e40f72aa"}, {"k": "NServiceBus.ConversationId", "v": "bda75aaa-eaf6-4640-971f-b34100c5e75f"}, {"k": "NServiceBus.CorrelationId", "v": "57670dea-7904-4a0f-b92e-2f66e40f72aa"}, {"k": "NServiceBus.ReplyToAddress", "v": "ADuplicateMessageArrives.OutboxEndpoint"}, {"k": "NServiceBus.OriginatingMachine", "v": "danielsacstudio"}, {"k": "NServiceBus.OriginatingEndpoint", "v": "ADuplicateMessageArrives.OutboxEndpoint"}, {"k": "$.diagnostics.originating.hostid", "v": "b65da644d5b5b3ee8cd445df3f7d13e9"}, {"k": "NServiceBus.ContentType", "v": "application/json"}, {"k": "NServiceBus.EnclosedMessageTypes", "v": "NServiceBus.AcceptanceTests.Outbox.When_a_duplicate_message_arrives+SendOrderAcknowledgement, NServiceBus.Storage.MongoDB.AcceptanceTests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"}, {"k": "NServiceBus.Version", "v": "10.0.0"}, {"k": "NServiceBus.TimeSent", "v": "2025-08-22 12:00:32:824299 Z"}]}]

"Body": new BinData(0, "eyJUZXJtaW5hdG9yIjpmYWxzZX0=")

represents {"Terminator":false}

After

[{"MessageId": "903e7729-eecf-4730-ab7a-b34100c516e9", "Options": [{"k": "Destination", "v": "ADuplicateMessageArrives.DownstreamEndpoint"}], "Body": new BinData(0, "eyJUZXJtaW5hdG9yIjp0cnVlfQ=="), "Headers": [{"k": "NServiceBus.MessageId", "v": "903e7729-eecf-4730-ab7a-b34100c516e9"}, {"k": "NServiceBus.MessageIntent", "v": "Send"}, {"k": "NServiceBus.RelatedTo", "v": "cf692566-98cd-4ce6-b2ef-b34100c516d6"}, {"k": "NServiceBus.ConversationId", "v": "6d9be290-f079-475d-8651-b34100c516d6"}, {"k": "NServiceBus.CorrelationId", "v": "cf692566-98cd-4ce6-b2ef-b34100c516d6"}, {"k": "NServiceBus.ReplyToAddress", "v": "ADuplicateMessageArrives.OutboxEndpoint"}, {"k": "NServiceBus.OriginatingMachine", "v": "danielsacstudio"}, {"k": "NServiceBus.OriginatingEndpoint", "v": "ADuplicateMessageArrives.OutboxEndpoint"}, {"k": "$.diagnostics.originating.hostid", "v": "b65da644d5b5b3ee8cd445df3f7d13e9"}, {"k": "NServiceBus.ContentType", "v": "application/json"}, {"k": "NServiceBus.EnclosedMessageTypes", "v": "NServiceBus.AcceptanceTests.Outbox.When_a_duplicate_message_arrives+SendOrderAcknowledgement, NServiceBus.Storage.MongoDB.AcceptanceTests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"}, {"k": "NServiceBus.Version", "v": "10.0.0"}, {"k": "NServiceBus.TimeSent", "v": "2025-08-22 11:57:34:854985 Z"}]}]

new BinData(0, "eyJUZXJtaW5hdG9yIjp0cnVlfQ==")

represents {"Terminator":true}

@danielmarbach danielmarbach merged commit 4bab95a into master Aug 22, 2025
4 checks passed
@danielmarbach danielmarbach deleted the rom branch August 22, 2025 13:21
@udidahan udidahan changed the title Outbox StorageOperations pass through body directly without copying Outbox StorageOperations should pass through body directly without copying Aug 24, 2025
@danielmarbach danielmarbach added this to the 6.0.0 milestone Sep 1, 2025
@danielmarbach danielmarbach changed the title Outbox StorageOperations should pass through body directly without copying Outbox storage operations pass through the body without copying Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants