[ https://issues.apache.org/jira/browse/CAMEL-21735?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17926345#comment-17926345 ]
Luis Sergio Faria Carneiro edited comment on CAMEL-21735 at 2/12/25 11:35 AM: ------------------------------------------------------------------------------ Great, I checked the docs. >From a developer experience perspective, it feels a little bit confusing to >use the mongodb component within a Camel K integration using the yaml dsl. I'm trying to setup integrations that connect to a source and a target mongo database, but I feel that the injected client is getting in the way. At the end, there are the hosts/username/password parameters which I cannot use, because the autowired connection is used instead. And if I need to change the default client, I have to do it using quarkus properties, which I managed to do. Now I will try to set up the 2 connection scenario, where I create clients, and configure them as described in [1]. I see that the MongoClient implementation does not have a no-parameters constructor, so it might not be straightforward to declare a bean using the yaml syntax. All the examples I have seen use wither the xml or java dsl. >From a personal perspective, I like the way the jdbc/sql components work, >where I can set up my Datasource beans and reference them in the endpoints >with no default datasource being created. On the mongodb extension, that default client to localhost might be handy for development environments, where the application and the database run on the same host, but that is not usually what we see in production environments. If we can get some enhancements either on the extension or the component that makes it simpler to use, that would be awesome. Thanks! [1] [https://camel.apache.org/camel-quarkus/3.15.x/reference/extensions/mongodb.html#extensions-mongodb-additional-camel-quarkus-configuration] was (Author: luiscarneiro): Great, I checked the code. >From a developer experience perspective, it feels a little bit confusing to >use the mongodb component within a Camel K integration using the yaml dsl. I'm trying to setup integrations that connect to a source and a target mongo database, but I feel that the injected client is getting in the way. At the end, there are the hosts/username/password parameters which I cannot use, because the autowired connection is used instead. And if I need to change the default client, I have to do it using quarkus properties, which I managed to do. Now I will try to set up the 2 connection scenario, where I create clients, and configure them as described in [1]. I see that the MongoClient implementation does not have a no-parameters constructor, so it might not be straightforward to declare a bean using the yaml syntax. All the examples I have seen use wither the xml or java dsl. >From a personal perspective, I like the way the jdbc/sql components work, >where I can set up my Datasource beans and reference them in the endpoints >with no default datasource being created. On the mongodb extension, that default client to localhost might be handy for development environments, where the application and the database run on the same host, but that is not usually what we see in production environments. If we can get some enhancements either on the extension or the component that makes it simpler to use, that would be awesome. Thanks! [1] https://camel.apache.org/camel-quarkus/3.15.x/reference/extensions/mongodb.html#extensions-mongodb-additional-camel-quarkus-configuration > MongoDB component connecting to localhost event if connection data is set > ------------------------------------------------------------------------- > > Key: CAMEL-21735 > URL: https://issues.apache.org/jira/browse/CAMEL-21735 > Project: Camel > Issue Type: Bug > Components: camel-mongodb > Affects Versions: 4.8.0 > Reporter: Luis Sergio Faria Carneiro > Priority: Major > > I'm trying to use the MongoDB component within a Camel K integration. And the > code is as following: > {code:java} > - to: > uri: mongodb:dummy > parameters: > operation: findAll > collection: environment > database: environments > username: someuser > password: somepass > hosts: somehost:27017{code} > Although the connection parameters are set, I see component trying to connect > to 127.0.0.1:27017. > Debugging the source code and checking the log, I see the component is using > an autowired client which is configured to localhost instead of creating a > new client from my parameters. > I haven't configured any beans. > But anyways, shoudn't the endpoint parameters take precedence over any > pre-configured bean which I'm not even aware of? > > > > > -- This message was sent by Atlassian Jira (v8.20.10#820010)