Map Wolverine TenantId from incoming MassTransit messages#3167
Closed
outofrange-consulting wants to merge 2 commits into
Closed
Map Wolverine TenantId from incoming MassTransit messages#3167outofrange-consulting wants to merge 2 commits into
outofrange-consulting wants to merge 2 commits into
Conversation
added 2 commits
June 19, 2026 15:54
…essages Add IMassTransitInterop.MapTenantIdFrom<T>(env => ...) so applications consuming MassTransit messages can derive Wolverine's Envelope.TenantId from either the message body or the MassTransit envelope metadata (headers, addresses, ids). The lambda receives a new public read-only view, IMassTransitEnvelope<T>, exposing the deserialized Message alongside the MassTransit metadata. The concrete MassTransitEnvelope<T> stays internal so the mutable serialization DTO is not leaked. Multiple message types compose; each mapper only fires for its own T and a null/empty result never clobbers an existing tenant id. Inbound (read) path only.
…nd SQS listeners UseMassTransitInterop(configure) dropped the configure lambda on the Rabbit MQ and Amazon SQS listeners: Rabbit MQ called InteropWithMassTransit() with no argument, and the SQS MassTransitMapper never received it. As a result any serializer customization (UseSystemTextJsonForSerialization, and now MapTenantIdFrom) silently no-opped on those transports while only Azure Service Bus honored it. Thread the configure action through to the MassTransit serializer on both. Covered by no-broker tests driving the Rabbit MQ deserialization pipeline end to end and the SQS mapper construction.
Member
|
Thanks @outofrange-consulting! Superseded by #3192, which retains your original commits (and authorship) and adds a small public-API rework on top: rather than introducing a new Closing in favor of #3192 — please follow along there. 🙏 |
jeremydmiller
added a commit
that referenced
this pull request
Jun 22, 2026
…-3167 Map Wolverine TenantId from incoming MassTransit messages (supersedes #3167)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
MapTenantIdFrom<T>hook to the MassTransit interop so applications consuming MassTransit messages can populate Wolverine'sEnvelope.TenantIdfrom each incoming message:The lambda receives a new public read-only view,
IMassTransitEnvelope<T>, exposing the deserializedMessagealongside the surrounding MassTransit metadata. The concreteMassTransitEnvelope<T>staysinternal, so the mutable serialization DTO is not leaked onto the public surface.Behavior:
T(re-registering the sameTreplaces the prior mapping).null/empty result never overwrites an existingTenantId.Drive-by fix
While wiring this up I found that
UseMassTransitInterop(configure)dropped theconfigurelambda on the Rabbit MQ and Amazon SQS listeners: Rabbit MQ calledInteropWithMassTransit()with no argument, and the SQSMassTransitMappernever received it. As a result any serializer customization — including the existingUseSystemTextJsonForSerialization, and nowMapTenantIdFrom— silently no-opped on those transports while only Azure Service Bus honored it. This is threaded through on both, in its own commit so it can be reviewed (or split) independently.Tests (no broker required)
MassTransitTenantMappingTests(CoreTests) — body mapping, header mapping, unregistered-type pass-through, empty-no-overwrite, multi-type dispatch, full-chain fall-through.masstransit_interop_map_tenant_id(RabbitMQ.Tests) — drives the full deserialization pipeline with a real MassTransit wire payload throughTryDeserializeEnvelope, proving theconfigurelambda reaches the listener. Uses stubbed transports.masstransit_mapper_tenant_mapping(AmazonSqs.Tests) — confirms the SQS mapper applies theconfigurelambda.Docs updated under
docs/guide/messaging/transports/rabbitmq/interoperability.md.dotnet build wolverine.slnx -c Releaseis clean locally.