camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Raible <m...@raibledesigns.com>
Subject Dynamic DataSource for SQL
Date Fri, 06 Jun 2014 22:08:53 GMT
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
Mime
View raw message