You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/10/06 13:06:31 UTC
[GitHub] [camel-karavan] Asraf-Uddin-Ahmed opened a new issue, #488: Need a sample code for MongoDB integration
Asraf-Uddin-Ahmed opened a new issue, #488:
URL: https://github.com/apache/camel-karavan/issues/488
I have a local MongoDB server with a _username_ and _password_ authentication. Here is the connection string:
```
mongodb://username%40email.com:password@localhost:27017/?directConnection=true&authMechanism=DEFAULT
```
The database name is `development` and the collection name is `users`.
I want to print here all the **last 5 users with odd IDs** for every day. `ID` is an _auto-increment_ field.
Can anyone help me?
--
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: commits-unsubscribe@camel.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] Asraf-Uddin-Ahmed commented on issue #488: Need a sample code for MongoDB integration
Posted by GitBox <gi...@apache.org>.
Asraf-Uddin-Ahmed commented on issue #488:
URL: https://github.com/apache/camel-karavan/issues/488#issuecomment-1274460756
Thanks, @davsclaus
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] Asraf-Uddin-Ahmed commented on issue #488: Need a sample code for MongoDB integration
Posted by GitBox <gi...@apache.org>.
Asraf-Uddin-Ahmed commented on issue #488:
URL: https://github.com/apache/camel-karavan/issues/488#issuecomment-1273327176
I have prepared the following script:
```
apiVersion: camel.apache.org/v1
kind: Integration
metadata:
name: dump-db-collections-to-avro-files
spec:
flows:
- route:
from:
uri: timer:mongo-timer
steps:
- toD:
uri: >-
mongodb:local-mongodb?hosts=localhost:27017&username=username%40email.com&password=pwd&database=staging&collection=Projects&operation=getDbStats
- log:
message: 'dumpMongoData: ${body}'
parameters:
period: '5000'
id: dumpMongoData
- beans:
- name: local-mongodb
type: "#class:org.apache.camel.component.mongodb.MongoDbComponent"
```
Here I am getting the following exception for this:
> Error processing exchange. Exchange[3839ECFFF76BA3F-0000000000000000]. Caused by: [org.apache.camel.ResolveEndpointFailedException - Failed to resolve endpoint: mongodb://local-mongodb?collection=Projects&database=staging&hosts=localhost%3A27017&operation=getDbStats&password=xxxxxx&username=xxxxxx due to: The connection string contains invalid user information. If the username or password contains a colon (:) or an at-sign (@) then it must be urlencoded]
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: mongodb://local-mongodb?collection=Projects&database=staging&hosts=localhost%3A27017&operation=getDbStats&password=xxxxxx&username=xxxxxx due to: The connection string contains invalid user information. If the username or password contains a colon (:) or an at-sign (@) then it must be urlencoded
at org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:985) ~[camel-base-engine-3.18.2.jar:3.18.2]
at org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:876) ~[camel-base-engine-3.18.2.jar:3.18.2]
at org.apache.camel.support.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:73) ~[camel-support-3.18.2.jar:3.18.2]
at org.apache.camel.support.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:122) ~[camel-support-3.18.2.jar:3.18.2]
at org.apache.camel.support.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:101) ~[camel-support-3.18.2.jar:3.18.2]
at org.apache.camel.processor.SendDynamicProcessor.resolveEndpoint(SendDynamicProcessor.java:296) ~[camel-core-processor-3.18.2.jar:3.18.2]
at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:157) ~[camel-core-processor-3.18.2.jar:3.18.2]
at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:477) ~[camel-core-processor-3.18.2.jar:3.18.2]
at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:189) ~[camel-base-engine-3.18.2.jar:3.18.2]
at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:61) ~[camel-base-engine-3.18.2.jar:3.18.2]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:182) ~[camel-core-processor-3.18.2.jar:3.18.2]
at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:399) ~[camel-base-engine-3.18.2.jar:3.18.2]
at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:210) ~[camel-timer-3.18.2.jar:3.18.2]
at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:76) ~[camel-timer-3.18.2.jar:3.18.2]
at java.util.TimerThread.mainLoop(Timer.java:556) ~[?:?]
at java.util.TimerThread.run(Timer.java:506) ~[?:?]
Caused by: **java.lang.IllegalArgumentException: The connection string contains invalid user information. If the username or password contains a colon (:) or an at-sign (@) then it must be urlencoded**
at com.mongodb.ConnectionString.<init>(ConnectionString.java:337) ~[mongodb-driver-core-4.6.0.jar:?]
at com.mongodb.client.MongoClients.create(MongoClients.java:61) ~[mongodb-driver-sync-4.6.0.jar:?]
at org.apache.camel.component.mongodb.MongoDbEndpoint.resolveMongoConnection(MongoDbEndpoint.java:348) ~[camel-mongodb-3.18.2.jar:3.18.2]
at org.apache.camel.component.mongodb.MongoDbEndpoint.doStart(MongoDbEndpoint.java:330) ~[camel-mongodb-3.18.2.jar:3.18.2]
at org.apache.camel.support.service.BaseService.start(BaseService.java:119) ~[camel-api-3.18.2.jar:3.18.2]
at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113) ~[camel-api-3.18.2.jar:3.18.2]
at org.apache.camel.impl.engine.AbstractCamelContext.deferStartService(AbstractCamelContext.java:1677) ~[camel-base-engine-3.18.2.jar:3.18.2]
at org.apache.camel.impl.engine.AbstractCamelContext.deferStartService(AbstractCamelContext.java:1654) ~[camel-base-engine-3.18.2.jar:3.18.2]
at org.apache.camel.impl.engine.AbstractCamelContext.internalAddService(AbstractCamelContext.java:1556) ~[camel-base-engine-3.18.2.jar:3.18.2]
at org.apache.camel.impl.engine.AbstractCamelContext.addService(AbstractCamelContext.java:1498) ~[camel-base-engine-3.18.2.jar:3.18.2]
at org.apache.camel.impl.engine.AbstractCamelContext.addService(AbstractCamelContext.java:1493) ~[camel-base-engine-3.18.2.jar:3.18.2]
at org.apache.camel.impl.engine.AbstractCamelContext.addService(AbstractCamelContext.java:1488) ~[camel-base-engine-3.18.2.jar:3.18.2]
at org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:969) ~[camel-base-engine-3.18.2.jar:3.18.2]
... 15 more
This problem occurs for `username=username%40email.com`. Here I have used a URL-encoded version of **"@"**, that is **"%40"**. This exception is not showing if I remove that **"%40"** part. BTW, My Java code is working fine.
Please help.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] Asraf-Uddin-Ahmed closed issue #488: Need a sample code for MongoDB integration
Posted by GitBox <gi...@apache.org>.
Asraf-Uddin-Ahmed closed issue #488: Need a sample code for MongoDB integration
URL: https://github.com/apache/camel-karavan/issues/488
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #488: Need a sample code for MongoDB integration
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #488:
URL: https://github.com/apache/camel-karavan/issues/488#issuecomment-1273722931
it may also be a good idea to allow configuring security settings on mondb component level so you dont have to use uris for that
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #488: Need a sample code for MongoDB integration
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #488:
URL: https://github.com/apache/camel-karavan/issues/488#issuecomment-1273722413
You can use RAW() syntax
https://camel.apache.org/manual/faq/how-do-i-configure-endpoints.html#HowdoIconfigureendpoints-Configuringparametervaluesusingrawvalues
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #488: Need a sample code for MongoDB integration
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #488:
URL: https://github.com/apache/camel-karavan/issues/488#issuecomment-1273724964
there is also the mongodb sink kamelet
https://camel.apache.org/camel-kamelets/0.9.x/mongodb-sink.html
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org