On Sat, Jan 3, 2009 at 10:51 AM, Bozo Juretic <bjure...@inet.hr> wrote:
> Hello all,
>
> what is the best practice of accessing the database to get dynamic routing
> info, from the RouteBuilder class in openesb environment through Camel SE.
Sounds like you talke about the dynamic router
http://activemq.apache.org/camel/dynamic-router.html

I dont think there is one best practice to access a DB. Use what means
you can or normally use. I like to use spring jdbc templates (or
ibatis in the past) as they are nice and easy and I can write the SQL
query to execute. Others jump on hibernate or JPA.

>
> I'm not really sure how and when and how many times is RouteBuilder class
> initialized so I would kindly ask you for a best practice. I use JPA in
> other EJBs in the system, but since RouteBuilder is not an EJB I'm not sure
> what is the best way to do it.
I don't know the internals of Camel SE in OpenESB. But the route
builder should only be initialized once, when it's started.
As Camel is very lightweight and usually embedded in other containers
it's that container's responsibility to handle CamelContext (that will
use the routerbuilder to build the routes) lifecycle.

> The same question for Processor() instances, if I need some database info
> for the processing in the same aforementioned environment, what is the best
> practice here as well.
If the container supports IoC it could inject the database DataSource
or what ever resource you use to access the DB. (You can also use
camel-sql, camel-jdbc etc.)
Then it could handle the lifecycle of the processor instance and you
can refer to it from the route builder

>
> Thank you and best regards,
>
> Bozo Juretic
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Reply via email to