Repository navigation
MassTransit interop keeps the inbox id of a durable envelope when it reads the messageId - #5398
Merged
Merged
Conversation
…reads the messageId MassTransitEnvelope.TransferData always replaced Envelope.Id with the MassTransit messageId when the handler pipeline deserialized the body. On SQS the MassTransit mapper leaves the id to the listener, which derives it from the SQS message, and the durable inbox stores the envelope under that id. Mark-handled, retry and dead-letter then matched no row, so the inbox row stayed Incoming and ran again on recovery. Same shape as the CloudEvents case in #5396. TransferData now leaves the id alone for an envelope that WasPersistedInInbox. Tests: CoreTests unit test, and an SQS (LocalStack) + PostgreSQL inbox test that fails without the fix with the row left Incoming. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sts are not MediatorOnly The GH-5391 test runs `codegen test` / `codegen write` through RunJasperFxCommands, which leaves the process-wide DynamicCodeBuilder.WithinCodegenCommand flag set. applyMetadataOnlyModeIfDetected then starts every later host in that test process in MediatorOnly mode, so whichever CoreTests ran after it in the same worker failed ("This operation is not allowed with Wolverine is bootstrapped in MediatorOnly mode") -- red on main at 6.62.1, green at a89e663, depending only on test order. Reset the flag after the commands and in finally, and run the class in a non-parallel collection so no host starts while the flag is set (the same arrangement Wolverine.Grpc.Tests uses for this flag). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The bug
MassTransitEnvelope.TransferDataalways replacedEnvelope.Idwith the MassTransitmessageId. It runs fromMassTransitJsonSerializer.ReadFromData, when the handler pipeline deserializes the body, which is after the durable inbox has already stored the envelope.On Amazon SQS the MassTransit mapper (
MassTransitMapper.ReadEnvelopeData) sets neither the id nor the message type. The listener derives the id from the SQS message, and the durable inbox stores the envelope under that id. Then:Envelope.Id= the MassTransitmessageId.Incomingand is run again on recovery.Reproduced against LocalStack with a PostgreSQL inbox, using
ListenToSqsQueue(...).UseMassTransitInterop().DefaultIncomingMessage<T>().UseDurableInbox()and a raw MassTransit body. The handler saw the MassTransit id, and the inbox row (stored under the SQS-derived id) was stillIncoming15 seconds after the handler finished.This is the same shape as the CloudEvents case in #5396.
The fix
TransferDataleavesEnvelope.Idalone when the envelopeWasPersistedInInbox. A non-persisted envelope still takes the MassTransitmessageId, and the correlation id, conversation id, headers, expiration and sent time are transferred as before.RabbitMQ and Azure Service Bus read the envelope id from the broker's own message id, which MassTransit sets to the same Guid as
messageId, so they were not affected in practice (from reading the code; not probed).Tests
MassTransitEnvelopeTests.an_envelope_held_in_the_inbox_keeps_the_id_it_was_stored_undermasstransit_interop_with_durable_inbox_keeps_inbox_id: SQS (LocalStack) + PostgreSQL inbox, asserting the row is not leftIncomingafter the handler succeedsBoth fail without the fix and pass with it. Also run locally: the CoreTests
Runtime.Interoptests, the RabbitMQ MassTransit tests, anddotnet build wolverine.slnx -c Release -f net9.0. After rebasing onto currentmain, the CoreTests interop tests were rerun (59 green). The SQS test was built but not rerun after the rebase, because the local containers were down.🤖 Generated with Claude Code