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 <m...@raibledesigns.com>: > 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