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

   [CAMEL-27148](https://issues.apache.org/jira/browse/CAMEL-27148)
   
   ## Problem
   
   An `idempotentConsumer` skips a duplicate by default (`skipDuplicate` is 
true): the duplicate never reaches the steps under it. It goes on to the steps 
after the `idempotentConsumer`, with the exchange property 
`CamelDuplicateMessage` set to true. A new message has no such property.
   
   So a check of `CamelDuplicateMessage` in the steps under such an 
`idempotentConsumer` is never true. In the local-model benchmark, 
route-enrich-and-dedupe step 1 asks to log "accepted" for a new order and "is a 
duplicate, skipped" for one seen before. The model wrote:
   
   ```yaml
   - idempotentConsumer:
       expression:
         simple: "${body[orderId]}"
       idempotentRepository: orderRepo
       steps:
         - choice:
             when:
               - expression:
                   simple: "${exchangeProperty.CamelDuplicateMessage} == true"
                 steps:
                   - log:
                       message: "Order ${body[orderId]} is a duplicate, skipped"
             otherwise:
               steps:
                 - log:
                     message: "Order ${body[orderId]} accepted"
   ```
   
   No duplicate is ever logged. With `== false` in the `when:`, every new order 
is logged as a duplicate.
   
   In the runs r30 to r35, the 8 step runs that checked the property without 
`skipDuplicate: false` all failed, and the 27 that set it all passed. The 
catalog does not tell it either: `skipDuplicate` says "Sets whether to skip 
duplicates or not", and the property says "Whether this exchange is a duplicate 
detected by the Idempotent Consumer EIP".
   
   ## Change
   
   `camel_write_file` and `camel_edit_file` of the camel-jbang-mcp server (and 
`camel_validate_source`) give a note for such an `idempotentConsumer`:
   
   ```
   Line N: this idempotentConsumer skips a duplicate (skipDuplicate is true by 
default): a duplicate never reaches the steps under it, so the check of the 
exchange property CamelDuplicateMessage there is never true. Add skipDuplicate: 
false, and a duplicate goes on to these steps with CamelDuplicateMessage set to 
true.
   ```
   
   When the steps check `== false`, the note adds: "Check == true for a 
duplicate (and otherwise: for a new message), not == false: a new message has 
no such property."
   
   It is a note like the other write notes, so the write is not refused. There 
is no note for:
   - `skipDuplicate: false`, or a value that is not plainly true, such as a 
placeholder;
   - a check after the `idempotentConsumer`, where a duplicate arrives with the 
property set.
   
   The descriptions of `skipDuplicate` and of `CamelDuplicateMessage` could say 
this too. That changes the model and its generated files, so it is left for 
another ticket.
   
   ## Tests
   
   - `WriteNotesTest`: the note for the route above; the extra sentence for `== 
false`; no note for `skipDuplicate: false`, a placeholder, or a check after the 
`idempotentConsumer`.
   - `AuthoringToolsEditTest`: a write gets the note and the line in its 
message, and the write with `skipDuplicate: false` gets neither.
   - camel-jbang-core, the `commands.ai` tests: 1097 run, 0 failures, 1 skipped.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_016Y4dDi5iQNgtHrDdz2NpwF
   


-- 
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