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

   Part of #3280: `mongodb-changes-stream-source` can resume after a restart. 
CAMEL-27195 asked for a way without a bean. The decision is to keep the token 
repository a bean, as with the `mongodb` component itself, so no Camel change 
is needed for this one.
   
   ### What changed
   - **The option:** a new optional `tokenRepository`, "a reference to a 
`StateRepository` bean that stores the resume token after each change". It is 
passed to camel-mongodb as `changeStreamTokenRepository`. The value starts with 
a placeholder, so the parameter is dropped when it is not set, and nothing 
changes then.
   - **The description:** the "Good to know" sentence that said the changes 
made during a restart are never sent now says how to keep them. The option says 
how to declare the bean, for example:
   
     ```yaml
     - beans:
         - name: changeStreamTokens
           type: org.apache.camel.support.processor.state.FileStateRepository
           properties:
             fileStore: "#class:java.io.File('/data/change-stream-tokens.dat')"
     ```
   
     with `tokenRepository: "#changeStreamTokens"`. A plain path does not work 
for `fileStore`: Camel does not convert the text to a `java.io.File` when it 
creates the bean, so the description gives the `#class:java.io.File(...)` form.
   
   ### Tests
   Checked with `camel run` against MongoDB 7 as a one-node replica set:
   1. The Kamelet with `tokenRepository` received document A, and wrote the 
resume token to the file.
   2. With the integration stopped, document B was inserted.
   3. After the restart, the Kamelet sent B.
   4. The same flow without `tokenRepository` did not send the document 
inserted while it was stopped, as before.
   
   `./mvnw clean install` from the root passes, run twice.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 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