DATAGO-68275: fix SolaceErrorMessageHandler acknowledgmentCallback detection and error handling #331
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.
This prevents an edge case of messages being stuck in an unacknowledged state when a
MessagingException
is thrown which contains afailedMessage
that doesn't have itsacknowledgmentCallback
header set.e.g.:
Issue 1: Detection of AcknowledgmentCallback
Currently, this binder's error message handler detects the message's
acknowledgmentCallback
in the following order of precedence, where upon first discovery, the other potential sources for this callback are not searched:errorMessage
's header.Message<?>
.MessagingException
that has afailedMessage
set, then get it from thatfailedMessage
.Message<?>
created by this binder's consumer binding.Fix: Detect and handle ack callback from all sources
Detect and handle
acknowledgmentCallback
from all potential sources.NOTE: Ideally, we should just ignore source 2 (
failedMessage
message set on theMessagingException
), but I wasn't sure if this would cause backwards incompatibility. @mgevantmakher @carolmorneau , if you think that this isn't a use case and I'm worrying for nothing, then I can just remove that source entirely...Issue 2: When the error message handler needs to fail
Currently, the error message handler just returns when it isn't able to process an error. This is faulty, since Spring will treat the errored message as "successfully handled", and returns control back to the binder as-if the message was processed successfully.
This results in the message getting acknowledged, and is the other contributor to the above issue.
Fix: Error handler should throw an exception when it isn't able to ack the message
Just throwing an exception instead of returning...