davsclaus opened a new pull request, #29558: URL: https://github.com/apache/camel/pull/29558
[CAMEL-26791](https://issues.apache.org/jira/browse/CAMEL-26791): a chaos rule with the `duplicate` fault sends a message twice, as a sender or broker that delivers again. Until now, no expectation could tell whether the receiver did the work twice. In a run of `camel cmd chaos-explore` (CAMEL-26760), 8 duplicate payments went through and the experiment passed. This adds that expectation: ``` endpoint=http://localhost:8080/payment duplicate rate=0.1 until=1m expect=payment:duplicates<=0 within=90s ``` **How it works** - **The key:** the route policy notes the key of each message as it enters the route. By default the key is the body as text, read so that a stream is cached rather than consumed. `key=` (Simple) gives a key when the body doesn't tell the messages apart, such as `key=${header.orderId}`, or a request with no body. A message without a key is not counted. - **What counts:** a message that completes in the route with a key that completed there before is a duplicate processed. It isn't counted if an idempotent consumer recognised it, because the idempotent consumer always sets `CamelDuplicateMessage` on a duplicate, with or without `skipDuplicate`. A route that recognises duplicates another way can set the same property. - **Counted per pass, not per exchange:** the second send of `SEND_TWICE` to a `direct` route is the same exchange again, and route counts take each exchange only once. A redelivery that calls a route again after it completed also did the work twice, so it counts. - **Operators:** `<=` or `=`. It is unmet as soon as the count goes over. The report gives `samples` and the text `2 duplicates processed (6 completed in payment)`. - **Suggestions:** `chaos-suggest` adds `expect=<receiver>:duplicates<=0` to a duplicate fault when a route of the integration receives the send: a `direct` or `seda` endpoint it consumes, or an HTTP call to this machine on the path of one of its `platform-http` routes. That's the payment route of the chaos example. - **Playbook:** the exploration playbook names the new expectation for a duplicate fault. **Tests:** `ChaosExpectDuplicatesTest` covers: - a `direct` receiver; - an idempotent consumer, whose duplicates aren't counted; - `key=` with a body that doesn't tell orders apart; - a real HTTP call to a netty-http route of the same context, with a stream body that the route can still read after the key was taken; - the operator and `key=` errors; - finding the receiver for a suggestion. The chaos model has the new `key` option and `duplicates` kind, and the catalog copies of the model and of `chaos.adoc` are regenerated. All 841 camel-chaos tests pass; tests that pin the list of kinds or options are updated. _Claude Code on behalf of Claus Ibsen_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS -- 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]
