Please have a look at components like PAX-JDBC[1] that helps in dynamic 
registrations of datasources with camel-blueprint. It also helps you in editing 
the same during runtime as well. I have a put a small sample of using it with 
camel and mybatis here[2]


[1] https://ops4j1.jira.com/wiki/display/PAXJDBC/Pax+JDBC

[2] https://github.com/kameshsampath/paxjdbc.camel.demo


Get Outlook for Android






On Tue, Jun 7, 2016 at 7:34 AM +0530, "Atsushi Matsumoto" 
<atsma...@yahoo-corp.jp> wrote:





Thank you for your quick reply.
I will check camel-scr and camel-blueprint and get back to you soon.
I am looking forward to your future support as well.

> -----Original Message-----
> From: Quinn Stevenson [mailto:qu...@pronoia-solutions.com]
> Sent: Friday, June 03, 2016 12:12 AM
> To: users@camel.apache.org
> Cc: 福田 奏 <kafuk...@yahoo-corp.jp>
> Subject: Re: Updating datasource at runtime with camel-sql
>
> 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 https://issues.apache.org/jira/browse/CAMEL-9570.
> 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 <atsma...@yahoo-corp.jp>
> 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=pas
> > sword");
> > registry.put("TestDB", datasource);
> >
> >
> > DSL using the datasource is:
> >
> >
> > <routes xmlns="http://camel.apache.org/schema/spring";>
> >        <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?

Reply via email to