This repository was archived by the owner on Sep 16, 2021. It is now read-only.
Repository navigation
Add route for retrying failed messages before sending to DLQ - #32
Merged
Merged
Conversation
Many exceptions (if not most) are recoverable, and it is burdensome to impose the contract of wrapping exceptions in RecoverableException when "necessary" (when would it be necessary?).
| private final Duration processTimeout; | ||
| private final String deadLetterUri; | ||
|
|
||
| private static final String NEXT_RETRY_ATTEMPT_NUMBER_PROPERTY = "eventHandlerFailedMessageNextRetryAttemptNumber"; |
Member
There was a problem hiding this comment.
How about just "current attempt number"?
Contributor
Author
There was a problem hiding this comment.
Done (went with "nextAttemptNumber" since current may be a little misleading)
Member
|
Overall, LGTM, I'd like to explore at some point in the future organizing the retry logic for readability-sake, but as stated in a comment, we can handle as a backlog item. Merge when ready. |
Contributor
Author
Would you mind opening an issue labeled under refactor to elaborate a little bit? Is there anything small we can do now? |
Member
Can't think of anything off the top of my head. |
Contributor
Author
|
Thank you! |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
As part of auditing how inbound messages will work, I am reworking the intended path for retries a bit.
Originally, I had (naively) hoped we will be able to generalize these enough such that failure scenarios (specifically around locking) would be predictable, but seeing our business logic this is not the case (surprise). So, instead of making a Message base which did some error handling, I opted to make routes which deal with messages more flexible WRT error handling.
Immediately you may notice I am not using Camel's error handling directly. I wanted to, but I could not make it fit naturally. The main reason is that Camel's error handling redelivery redelivers the exchange as it existed before the processor that failed, at the processor that failed. Because we are processing messages in batch in one exchange, this would cause already succeeded messages to be reprocessed. This is not fatal, but it is easy enough to prevent this case that I think it is worth trying. Secondarily, Camel's error handling works expecting exchanges which throw exceptions, and in our routes we deal with failure in batches, and retain more context about the failures, so we use collections of failure messages which can be routed instead of throwing exceptions (this already existed prior to this PR). Camel's error handling fits more naturally when an exchange represents one individual message, not a batch. When using a route with a loop() processor instead I found much less friction.
I also got rid of the RecoverableException idea, which is no longer necessary, and would've been a surprising contract to follow given the variety of errors that can happen when processing inbound messages. I think ultimately error handling behavior will be more effective and predictable letting message processing throw whatever exception and retrying always. If we wanted, we could easily customize which kinds of exceptions cause retries, but I think for now we can put this off for later.