Hello Andrei,

This is an interesting use case.

Currently there is no easy way to support your scenario because the MongoDB
component requires a com.mongodb.Mongo bean in the registry, e.g.

    mongodb:connectionBean?...

In your context:

    <bean name="connectionBean" class="com.mongodb.Mongo">
       ...
    </bean>

However, many ideas come to mind. You can use a Dynamic Router / Recipient
List EIP to dynamically change the endpoint URI, along with Camel's Java
API to dynamically register beans in the registry [3].

So when you receive a message, a Processor or a bean could bind a new Mongo
object in your registry under a random UUID. You set the resulting UUID in
an Exchange property. Then you use that UUID to populate the endpoint URI,
e.g. mongodb:<uuid>.

Once the operation is finished, you can unbind the bean from the registry
(Very important to do so! Otherwise you could easily end up with a memory
leak).

[1] https://camel.apache.org/dynamic-router.html
[2] https://camel.apache.org/recipient-list.html
[3]
http://camel.465427.n5.nabble.com/Programatically-adding-beans-to-a-registry-in-a-RouteBuilder-td5729358.html

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 Mon, Aug 25, 2014 at 9:36 AM, Andrei Stoica <
andrei.ionut.sto...@gmail.com> wrote:

> Hello,
>
> My problem is that the connection URI might change and I need a way to edit
> it at runtime.
>
> When the application will be started, the user will be prompted with a
> screen to input the connection details. After he inputs them, I need a way
> to route messages to that URI.
>
> Any idea how I can do that?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/mongoDB-uri-tp5755565p5755625.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply via email to