FAQ
A similar question was asked on Stack Overflow two months ago. A solution
is posited by the author who also made a suggestion for making this use
case easier.

http://stackoverflow.com/questions/31604721/using-a-custom-registry-in-a-camel-application
On Thu, Feb 5, 2015 at 7:46 AM, Camel Guy wrote:

I see this is fixed in 15.0. I can use the snapshot but how do I use this
feature?

By the way, this is my solution for IMO a shortcoming in Camel (after
using it for a year) - the inability to pass objects to consumers except
via essentially static beans or something like ehcache. I'm using addRoute
at runtime with dynamically generated from Uris. If you need to pass
something more complex than a sting to a consumer, and it changes at
runtime, times are hard.

Thanks,

cg


On Thursday, November 20, 2014, Willem Jiang wrote:

Camel look up the DataSource object from the camel context registry.
If you can change the registry dynamically, you can change the data
source for the camel-jdbc component just as you said in the first mail.

The key point is you need to replace the old CamelContext Registry by a
new CompositeRegistry just as CAMEL-8048[1] does.

[1]https://issues.apache.org/jira/browse/CAMEL-8048

--
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem


On November 21, 2014 at 4:52:41 AM, Camel Guy (camel@devguy.com) wrote:
Thanks Willem.

I can make that work! It's just a headache to get a new data source
instance initialized with data that is in Exchange. (Very dynamic data
source..)

Maybe I should instead be asking for the ability to pass a datasource
to the jdbc component via a header.
On Wed, Nov 19, 2014 at 11:07 PM, Willem Jiang wrote:
You can define a factory bean to instantiate the data source.
When the object export with the name A, camel can look it up from the
Spring application
context.
--
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem



On November 20, 2014 at 1:21:38 PM, Camel Guy (camel@devguy.com)
wrote:
Hello,

I was wondering if a route could invoke a bean (or run, say, a groovy
script) that registered a new datasource.

Something like:

route ::
1) Instantiate datasource
2) Add datasource instance to the registry under key A
3) recipientList("jdbc:A?...")

This datasource needs to be created long after Camel starts up.

I'm using Spring XML.


Thank you,
~cg

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 6 | next ›
Discussion Overview
groupusers @
categoriescamel
postedNov 20, '14 at 5:21a
activeOct 20, '15 at 3:15a
posts6
users2
websitecamel.apache.org

2 users in discussion

Camel Guy: 4 posts Willem Jiang: 2 posts

People

Translate

site design / logo © 2021 Grokbase