Hi
If you se <to> then the uri is computed statically, eg once when the route is initialized. So the "dynamic to" is a good practice for dynamic uris http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html As you can the pass in the dataSource parameter dynamically. As well construct the SQL dynamic too. And if you want this CASE SELECT construct in the routes as well, then you can use the content based router. But having that logic in a java class is maybe better. On Sat, Jun 7, 2014 at 5:31 PM, Antoine DESSAIGNE <[email protected]> wrote: > Hello Matt, > > You'll have to use the recipient list [1] pattern: > > from("direct:projects") > .setProperty("ds", /* logic to convert client param to datasource name > */) > .setHeader("target", simple("sql:select * from projects order by > id?dataSource=${property.ds}") > .recipientList(header("target")) > .to(/* what you would do next after the SQL request */) > > Antoine. > > [1] http://camel.apache.org/recipient-list.html > > > 2014-06-07 0:08 GMT+02:00 Matt Raible <[email protected]>: > >> Hello, >> >> I'm converting services written with IBM Message Broker 6.1 to Apache >> Camel. Here's some of the logic I'm trying to convert: >> >> SET Environment.Variables.dataSource = ''; >> CASE UPPER(InputRoot.XMLNSC.ns:memberLookupRequest.ns:args0.ax21:Client) >> WHEN 'client1' THEN SET Environment.Variables.dataSource = 'foo'; >> WHEN 'client2' THEN SET Environment.Variables.dataSource = 'bar'; >> WHEN 'client3' THEN SET Environment.Variables.dataSource >> = 'baz'; >> END CASE; >> >> Basically, a parameter comes in and the dataSource is dynamically >> configured based on it. What's the best way to do this with Apache Camel? >> I'm guessing something like this might work (adopted from >> http://camel.apache.org/sql-component.html): >> >> from("direct:projects") >> .setProperty("ds", /* logic to convert client param to datasource name >> */) >> .to("sql:select * from projects order by id?dataSource=#${property.ds}") >> >> Is this the best way to configure dynamic datasources? For each >> datasource, I realize I'll have to configure it as a @Bean with Spring's >> JavaConfig. >> >> Thanks, >> >> Matt -- Claus Ibsen ----------------- Red Hat, Inc. Email: [email protected] Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
