gnodet opened a new pull request, #22300: URL: https://github.com/apache/camel/pull/22300
## Summary Enhances the Splitter EIP with three new features that were previously proposed as a standalone `camel-bulk` component (CAMEL-23240, PR #22159). After analysis, these features compose naturally with the existing Splitter and benefit from a first-class DSL integration rather than a separate component. ### New DSL options - **`group(int)`** — Chunks split items into `List` batches of N. Wraps the underlying iterator with `GroupIterator`. More discoverable than the existing `collate(n)` Simple expression and works with any split expression. - **`errorThreshold(double)`** — Aborts when the failure ratio exceeds the threshold (0.0–1.0). For example, `errorThreshold(0.5)` stops when more than 50% of items fail. Mutually exclusive with `stopOnException`. - **`maxFailedRecords(int)`** — Aborts after N item failures. Mutually exclusive with `stopOnException`. Can be combined with `errorThreshold`. - **`SplitResult`** exchange property — When error thresholds are configured, a structured `SplitResult` is set as an exchange property (`CamelSplitResult`) after split completion. Provides `totalItems`, `failureCount`, `successCount`, individual `Failure` details (index + exception), and an `aborted` flag. ### Implementation approach - Extracted `shouldContinueOnFailure()` as a protected method in `MulticastProcessor`, replacing the inline `stopOnException` check. 100% backward-compatible: all existing EIPs (Multicast, RecipientList) behave identically. - `Splitter` overrides `shouldContinueOnFailure()` to track failures in a thread-safe `SplitFailureTracker` (uses `AtomicInteger` + `CopyOnWriteArrayList` for parallel mode safety). - New fields use setter methods (following `setSynchronous`/`setDisabled` pattern) rather than extending the already-long constructor. ### Files changed | Module | File | Change | |--------|------|--------| | camel-api | `SplitResult.java` | New class with `Failure` record | | camel-api | `Exchange.java` | Added `SPLIT_RESULT` constant | | camel-api | `ExchangePropertyKey.java` | Added `SPLIT_RESULT` enum | | camel-core-model | `SplitDefinition.java` | Added `group`, `errorThreshold`, `maxFailedRecords` fields + fluent methods | | camel-core-processor | `MulticastProcessor.java` | Extracted `shouldContinueOnFailure()` method | | camel-core-processor | `Splitter.java` | Added group/error threshold/SplitResult implementation | | camel-core-reifier | `SplitReifier.java` | Wiring + mutual exclusivity validation | | camel-yaml-dsl | `ModelDeserializers.java` | Regenerated | ## Test plan - [x] `SplitterGroupTest` — 4 tests: group=3 with 7 items, exact multiple, single item, parallel processing - [x] `SplitterMaxFailedRecordsTest` — 4 tests: stops after threshold, all succeed, single failure (below threshold), mutual exclusivity with stopOnException - [x] `SplitterErrorThresholdTest` — 4 tests: stops when ratio exceeded, below ratio continues, all succeed, mutual exclusivity with stopOnException - [x] `SplitterSplitResultTest` — 4 tests: result with failures, result when aborted, result with all success, no result without error threshold - [x] All 121 existing `Splitter*Test` tests pass (0 regressions) Supersedes #22159 (camel-bulk component, closed). JIRA: https://issues.apache.org/jira/browse/CAMEL-23264 -- 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]
