2009/1/3 Bozo Juretic <bjure...@inet.hr>:
> 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.

I just wondered if you could give specifics for how you'd use the
database to get dynamic routing info?  Is it you'd like to do some
custom processing in a bean taking some contents or headers of a
message and use it to find some value in some table and use that
result to decide what endpoint to send it on to?

If so you can do that in a single method...
http://activemq.apache.org/camel/recipientlist-annotation.html

public class RouterBean {

    @Consume(uri = "activemq:someQueue")
    @RecipientList
    public String[] route(@Header("cheese") String cheese, String body) {
        // do some database query or something or other

        // lets return some endpoint(s) to route to...
        return new String[]{"activemq:bar", "activemq:whatnot"};
    }
}

Or is it more a case you want to store entire route definitions inside
the database? You could store blobs of XML in the database if you
want?


> 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.
>
> 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.

As Claus said, use whatever API or framework you prefer - be it direct
hibernate, JPA, iBatis, raw JDBC or Spring JDBC templates etc. Just
write Java code as a bean and then invoke it from your route. For more
info see

http://activemq.apache.org/camel/bean-binding.html

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Reply via email to