allthingssecurity opened a new pull request, #26814:
URL: https://github.com/apache/camel/pull/26814

   # Description
   
   [CAMEL-24953](https://issues.apache.org/jira/browse/CAMEL-24953)
   
   With `skipDuplicate(false)`, a duplicate is routed on with 
`CamelDuplicateMessage=true`, but `IdempotentConsumer.process` registered the 
same `IdempotentOnCompletion` for it as for a new message. If the duplicate 
failed, the completion removed the message id that the *original* exchange had 
added (`removeOnFailure=true` is the default). The next copy was then processed 
again, and in eager mode (the default) that could happen while the original was 
still in flight.
   
   This change: the `IdempotentOnCompletion` is only registered for a new 
message. A routed duplicate still gets the `CamelDuplicateMessage` property, 
the duplicate counter and `onDuplicateMessage`, but it never calls `add`, 
`confirm` or `remove` on the key it doesn't own. New messages behave as before 
for every combination of `eager`, `completionEager` and `removeOnFailure`.
   
   Tests: new `IdempotentConsumerFailedDuplicateTest`. It covers the sequential 
case with eager, completionEager and non-eager, and a concurrent eager case 
where the first exchange is held in the route by a latch while a duplicate 
fails. Without the fix all 4 fail with `The failed duplicate must not remove 
the key added by the first exchange ==> expected: <true> but was: <false>`. 
With the fix: `*Idempotent*`, `KeyValue*`, `Cache*` and `*Aggregat*` in 
camel-support and camel-core, 43 + 332 tests, 0 failures.
   
   The JIRA ticket raises a related question that this PR doesn't change: in 
non-eager mode, a failing exchange that never added the id can still remove one 
another exchange committed.
   
   Found with a TLA+ model of the Idempotent Consumer, then reproduced against 
the real classes.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built and tested the affected modules, including the formatter and 
import-sort plugins. I did not run the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5), on behalf of 
allthingssecurity. The commits carry a `Co-Authored-By` trailer.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to