CMessagingEndpoint - URI with dynamic parameters

Highlighted
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!
Highlighted
Community Manager

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.
Highlighted
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!
Highlighted
Community Manager

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.

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read