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

   # Description
   
   [CAMEL-25864](https://issues.apache.org/jira/browse/CAMEL-25864)
   
   Every Aggregate EIP without a repository wraps the single 
`KeyValueRepository` of the registry in a `KeyValueAggregationRepository`, and 
since CAMEL-25819 each of them runs a recover task. The completed exchanges 
were all kept under the same `completed:` prefix, and `scan` returns all of 
them. So the recover task of one aggregator found the exchanges that another 
aggregator had completed and was still processing (or that had failed on the 
other route), marked them redelivered and sent them on its own route. The 
exchange is delivered twice, once on a route that has nothing to do with it.
   
   Changes:
   - `KeyValueAggregationRepository`: a new constructor with a recovery name. 
With a name, the completed exchanges are kept, scanned, recovered and confirmed 
under `completed[<name>]:<exchangeId>`, which an adapter without a name (prefix 
`completed:`) does not scan. Open groups keep their 
`aggregate:<correlationKey>` keys. No new bean property, so the generated 
metadata does not change.
   - `AggregateProcessor`: the adapter it creates for an auto-discovered 
repository is named after the route id and the id of the aggregator 
(`<routeId>/<id>`).
   
   What is not changed:
   - Open groups: aggregators that share an auto-discovered repository and get 
the same correlation key still share the open group under 
`aggregate:<correlationKey>`, as in 4.23 (like several Cache EIPs that share 
one auto-discovered repository, see the note on the Cache EIP page). Keeping 
the groups apart too would change the keys of groups that are open in a 
persistent store across the upgrade, so I will open a follow-up JIRA for it 
instead of doing it here.
   - The name comes from the route id and the id of the aggregator, which Camel 
generates (`route1`, `aggregate1`) when they are not set. With a persistent 
store, a completed exchange is recovered after a restart by the aggregator with 
the same name, so routes and aggregators should have explicit ids if routes can 
be added or reordered between restarts (as for any state kept per route).
   
   Completed entries that an auto-discovered adapter wrote under `completed:` 
in 4.23.x were never recovered there (CAMEL-25819 is in 4.24.0 only) and are 
not picked up by the named adapters. No upgrade guide entry, as the recover 
task of an auto-discovered repository is new in 4.24.
   
   Tests:
   - New `AggregateAutoDiscoveredKeyValueRepositorySharedTest` (camel-core): 
two routes with an aggregator and one `MemoryKeyValueRepository` bean; the 
orders route completes a group and holds the aggregated exchange downstream 
across the recover scans. Without the change: `mock://invoices Received message 
count. Expected: <0> but was: <1>`. With it, the invoices route gets nothing, 
the orders route gets "A+B" once and the repository is empty at the end.
   - 
`KeyValueAggregationRepositoryTest.testRecoveryNameKeepsCompletedExchangesApart`:
 two named adapters and an unnamed one over one store each scan and recover 
only their own completed exchanges.
   - camel-core `org.apache.camel.processor.aggregator.**`, 
`org.apache.camel.support.**` and the other aggregate tests: 707 run, 0 
failures, 3 skipped. camel-support: 136 run, 0 failures. 
`AggregateAutoDiscoveredKeyValueRepositoryRecoverTest` (CAMEL-25819) still 
passes.
   
   How it was found: a review of the changes merged to main in the last week 
(CAMEL-25819), looking at what the change made reachable, then the JUnit test.
   
   What was not run: the whole camel-core test suite; the root build.
   
   # 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): 
[CAMEL-25864](https://issues.apache.org/jira/browse/CAMEL-25864).
   
   # 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 camel-api, camel-support, camel-core-processor and camel-core; 
the change adds no option, so nothing is generated. 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). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 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