CMessagingEndpoint - URI with dynamic parameters

One Star

CMessagingEndpoint - URI with dynamic parameters

Hi,
how can I add a dynamic value to the URI of cMessagingEndpoint?
Example:
I want so select data from database where id = <param>
The value for <param> is hold in header of the message.
I try to do like this, but that was not successfull:
"sql:select * from table where id = ${header.id}?dataSourceRef=myDS"


Thanks for help!
Sixteen Stars

Re: CMessagingEndpoint - URI with dynamic parameters

Unfortunately as soon as the route is started, the endpoints are fixed. You can use code to start and stop sub-routes. This would allow you to stop a sub-route, change its endpoint and restart it, but that takes a fair bit of code and is not ideal. An easier way of achieving this might be to use a cTalendJob. You can send the message to the cTalendJob, the job called by the cTalendJob will act (give or take) just like a normal Talend job, which means you can easily use dynamic SQL. You can then return your message to the route.
One Star

Re: CMessagingEndpoint - URI with dynamic parameters

This code works:
"sql:select * from table where id=:#${header.id}?dataSourceRef=myDS"

The problem was the missing ":#" before the parametervalue!
Sixteen Stars

Re: CMessagingEndpoint - URI with dynamic parameters

I didn't know this. I was basing my answer on trying to change direct and vm endpoints dynamically. Nice to know.