Federico Mariani created CAMEL-27056:
----------------------------------------
Summary: camel-mongodb - connectionUriString without hosts is not
used: the endpoint connects with the MongoClient of the component or registry
instead
Key: CAMEL-27056
URL: https://issues.apache.org/jira/browse/CAMEL-27056
Project: Camel
Issue Type: Bug
Components: camel-mongodb
Reporter: Federico Mariani
When a mongodb endpoint sets {{connectionUriString}} without {{hosts}}, the
endpoint does not create a client from the connection string. It uses the
{{MongoClient}} of the component instead (autowired when the registry holds
exactly one, for example the default client of the runtime), or else looks up
the endpoint path as a {{MongoClient}} bean.
{code:java}
from("direct:save")
.to("mongodb:dummy?connectionUriString=RAW(mongodb://orders-db:27017)&database=orders&collection=orders&operation=insert");
{code}
* With a {{MongoClient}} in the registry, the documents are written to the
server of that client, not to {{orders-db}}.
* Without one, the endpoint fails to start with {{NoSuchBeanException: No bean
could be found in the registry for: dummy of type:
com.mongodb.client.MongoClient}}.
The connection string is only read when {{hosts}} is set as well.
Expected: as for {{hosts}} (CAMEL-21735), an endpoint with
{{connectionUriString}} creates its client from it and does not use the client
of the component or the {{connectionBean}}. The {{mongoConnection}} endpoint
option keeps precedence.
_Claude Code on behalf of Federico Mariani_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)