Particular / NServiceBus

Build, version, and monitor better microservices with the most powerful service platform for .NET
https://particular.net/nservicebus/
Other
2.08k stars 648 forks source link

[Backport to 9.1] Fixes the ingestion of physical messages containing multiple logical messages (#7129) #7130

Closed mauroservienti closed 1 month ago

mauroservienti commented 1 month ago

Symptoms

When NServiceBus v9.1.0 attempts to process message payloads containing multiple logical messages, an exception is thrown:

System.ArgumentException: An item with the same key has already been added. Key: nservicebus.message_handler_types

Who's affected

You are affected if you use legacy versions of NServiceBus (v5 or prior) that communicate with NServiceBus endpoints with version 9.1.0 and send multiple logical messages in a single payload.

Root cause

Previous versions of NServiceBus supported sending multiple logical messages per physical message. This resulted in an issue when collecting metric tags, which is resolved in this PR.

This issue also surfaced in ServiceControl when using the NServiceBus.Metrics.ServiceControl package as it batches multiple logical messages in the same physical message.


Backport of https://github.com/Particular/NServiceBus/pull/7129 to 9.1