camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Quinn Stevenson <>
Subject Re: Updating datasource at runtime with camel-sql
Date Thu, 02 Jun 2016 15:12:26 GMT
If you’re willing to use camel-scr or camel-blueprint, you can make this happen pretty easily.

You’d expose the data source as a service, and then inject it into the route - the exact
method would change based on whether you’re using camel-scr or camel-blueprint.

If you’re using camel-scr, when the service changes, the route will restart and pickup the
new service.

If you’re using blueprint, the route should just switch to the new service - but you may
get hit by  If you do, you can put in a
service registration listener to restart the route when the service changes as a temp fix.

> On Jun 1, 2016, at 10:36 PM, Atsushi Matsumoto <> wrote:
> Hi,
> Is it possible to update datasource that SqlComponent refers to at runtime?
> The datasource I want to update is bound to "TestDB" by registry in CamelContext as follows:
> BasicDataSource datasource = new BasicDataSource();
> datasource.setUrl("jdbc:mysql://hostname/dbname?user=user&password=password");
> registry.put("TestDB", datasource);
> DSL using the datasource is:
> <routes xmlns="">
>        <route>
>                <from uri="direct:hoge" />
>                <to uri="sql:SELECT * FROM test?dataSource=TestDB" />
>                <marshal>
>                        <json library="Jackson" />
>                </marshal>
>        </route>
> </routes>
> This DSL is successfully executed, the SQL returning right results.
> Next, I updated the datasource:
> registry.put("TestDB", newDatasource);
> Then I ran the DSL again, hoping that the DSL used the new datasource, but the SQL used
the old one.
> I think I can update the datasource if I run the DSL after doing removeRoute and AddRoute,
but I don't want to do removeRoute and AddRoute due to performance cost.
> Are there any ways?

View raw message