camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Dynamic DataSource
Date Fri, 11 Sep 2015 06:53:35 GMT
You can build the uri dynamic as in this FAQ
http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html

On Thu, Sep 10, 2015 at 1:56 PM, arnaud <arnaud.mercier@free.fr> wrote:
> Hello,
>
> Id'like to use a dynamic datasource with the camel-sql component but it's
> not woking as I expected:
> After a search on the forum, I have found a topic "Dynamic DataSource for
> SQL", I try to do something similar :
>
> from("direct:create")
> .setHeader("dataSource", constant("myDynamicDataSource"))
> .setHeader(SqlConstants.SQL_QUERY, simple("insert into customer(firstname,
> lastname) values(:?firstName, :?lastName)"))
> .setHeader("destination", new
> QueryBuilder()).recipientList(header("destination"));
>
> class QueryBuilder implements Expression {
>
>         @Override
>         public <T> T evaluate(Exchange exchange, Class<T> type) {
>
>                 StringBuilder query = new StringBuilder();
>                 query.append("sql:");
>                 query.append(exchange.getIn().getHeader(SqlConstants.SQL_QUERY));
>                 query.append("?dataSource=#");
>                 query.append(exchange.getIn().getHeader("dataSource"));
>
>                 return exchange.getContext().getTypeConverter().convertTo(type,
> query.toString());
>         }
> }
>
> But I have this error message :
> Failed to resolve endpoint:
> sql://insert%20into%20customer(firstname,%20lastname)%20values(:?firstName%2C+%3A%3FlastName%29%3FdataSource=%23myDynamicDataSource
> due to: DataSource must be configured
>
> Any idea of the problem or another solution to implement a dynamic
> datasource?
>
> Thanks,
> Arnaud
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Dynamic-DataSource-tp5771402.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition:
https://www.manning.com/books/camel-in-action-second-edition

Mime
View raw message