Did you just need to change the MongoDB Database and the MongoDB Collections?
I thought you also wanted to change the hostname and the port at runtime of the Mongo server... If that's not the case, you can even simplify your solution a lot! After all, it seems that your dynamic router is always returning the same URI... Regards, *Raúl Kripalani* Apache Camel PMC Member & Committer | Enterprise Architect, Open Source Integration specialist http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani http://blog.raulkr.net | twitter: @raulvk On Tue, Aug 26, 2014 at 2:03 PM, Andrei Stoica < andrei.ionut.sto...@gmail.com> wrote: > I managed to get it work this way: > > In the camel.xml I declared my bean: > > <bean id="myDb" class="com.mongodb.Mongo" /> > > my route: > > from("jms:mongoQueue") > .bean(MongoConnection.class, "setConnectionBean") > .process(new Processor() { > > @Override > public void process(Exchange exchange) throws > Exception { > > > exchange.getIn().setHeader(MongoDbConstants.DATABASE, "dbname"); > > exchange.getIn().setHeader(MongoDbConstants.COLLECTION, "collection"); > > exchange.getIn().setHeader(MongoDbConstants.OPERATION_HEADER, > "operation"); > exchange.getIn().setBody(query); > } > }) > .dynamicRouter(method(MongoConnection.class, > "getConnection")) > > and the MongoConnection.class: > > @Autowired > private Mongo mongo; > > public String getConnection(String body, > @Header(Exchange.SLIP_ENDPOINT) > String previous) throws Exception{ > > if(previous == null) > return > "mongodb://myDb?database=none&collection=none&dynamicity=true"; > else > return null; > } > > public void setConnectionBean(MongoStep step) throws > UnknownHostException{ > > MongoClientURI uri = new MongoClientURI(getUri()); > mongo = new MongoClient(uri); > } > > Now I can specify the uri in the runtime. > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/mongoDB-uri-tp5755565p5755704.html > Sent from the Camel - Users mailing list archive at Nabble.com. >