Ayush0612005 opened a new pull request, #31340: URL: https://github.com/apache/camel/pull/31340
# Description [CAMEL-27937](https://issues.apache.org/jira/browse/CAMEL-27937): the camel-mongodb problems found while improving its option descriptions (#31191). 1. **Tailable consumer options are validated.** `createConsumer` now resolves the consumer type before `validateConsumerOptions()`, so a tailable consumer (the default) without `tailTrackIncreasingField`, or with `persistentTailTracking` but no `persistentId`, fails to start instead of re-reading the whole capped collection on every new cursor. The producer check uses the `consumerType` option, since `dbConsumerType` is only set when a consumer is created. 2. **`writeConcern` is applied consistently.** The option has no default value anymore: when it is not set, the write concern of the client is kept (for example `w=majority` in `connectionUriString`, or a `MongoClient` from the registry). When it is set, it is applied to whichever collection the exchange uses, including the database and collection of the `CamelMongoDbDatabase` and `CamelMongoDbCollection` headers. 3. **`findDistinct` reads values of any type.** The values are read as `BsonValue` and converted to the Java type a `Document` holds (Integer, Long, Date, ObjectId, ...), in a `List<Object>`, so numeric and date fields no longer fail with a BSON decoding error. String fields still give Strings. 4. **Credentials are percent-encoded.** With `hosts`, the username and password are encoded in the connection string as `SslAwareMongoClient` already does (sharing its `encode`), so `@`, `:`, `/`, `%` and spaces reach the server as they are. 5. **The stored change stream token wins.** When `changeStreamTokenRepository` holds a token, the consumer resumes after it; `changeStreamToken` is only the starting point until a token has been stored. The option description and `ChangeStreamCommitManagerTest` are updated, as they documented the previous order. From item 6: - `collectionIndex` keeps the order of the JSON object (a `LinkedHashMap` instead of a `HashMap`). It still creates one index per field, as the option description says; a compound index would change documented behavior, so I left it out. Happy to add it as an option if you'd like. - `validateOutputType` is removed rather than called: it allowed `MongoIterable` with `findAll` only, while the `outputType` description and `MongoDbAggregateOperationIT` use it with `aggregate` too, so calling it would reject valid routes. The upgrade guide for 4.25 describes the changes in behavior (items 1, 2, 3, 5 and 4). The component JSON, the catalog copy and the endpoint DSL are updated for the `writeConcern` and `changeStreamToken` descriptions. # Tests - `MongoDbEndpointOptionsValidationTest`: a tailable consumer without `tailTrackIncreasingField` (default and explicit type), persistent tail tracking without `persistentId`, and a producer with `consumerType` are rejected. - `MongoDbProducerWriteConcernAndDistinctTest`: without the option the write concern of the client is kept; with `writeConcern=MAJORITY` it is applied, also to the collection of the `CamelMongoDbCollection` header; `findDistinct` returns an Integer, a Date and a String. - `MongoDbEndpointCredentialsTest`: a username and password with reserved characters reach the driver unchanged. - `MongoDbEndpointCreateIndexTest`: the indexes keep the order of the JSON object. - `ChangeStreamCommitManagerTest`: the stored token wins over `changeStreamToken`, which is used while the repository is empty. With the main changes reverted, each of these fails. The unit tests of camel-mongodb pass (1141). I could not run the integration tests (no Docker on this machine). # 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). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [x] I built camel-mongodb with `install` (including `formatter:format` and `impsort:sort`). _Claude Code on behalf of Ayush0612005_ -- 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]
