Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
n999
Contributor II
Contributor II

tcontextLoad in routes

Hi

I know you can use a tContext Component in a job or the implicit tContextLoad functionality to load context variables from a file.

I was wondering how you would do the equivalent inside a talend route?

Cheers

n999

Labels (3)
12 Replies
Anonymous
Not applicable

This is MUCH harder inside routes. You need to use Property Placeholders. There is no easy way to do this other than spending a while trying it out. Take a look here: http://edwardost.github.io/cloud/platform/soa/2015/05/14/Working-with-Property-Placeholders-in-Talen...

 

That tutorial is what got me going with these. Once you get the hang of it, it is really powerful.

n999
Contributor II
Contributor II
Author

thanks for that - very useful

 

I'm a java developer versed in Spring so this makes more sense that context loading.

I'm assuming I can use the same project level property file for context loading and property placeholder for jobs and routes within one project...

 

Would be interesting to see what Talend's official line is too....I couldn't find anything in help.talend.com...maybe they defer to spring/camel set up...

 

Anonymous
Not applicable

Talend ESB is essentially just a wrapper around Apache Camel. You can configure most of what you will need to configure within the Studio, but it might make sense to configure either a Blueprint or Spring file with DB connection pooling ,etc, and deploy that manually inside the Karaf. You may/may not have seen this, but you can make use of Spring within the Studio. There will be a Spring file for each of your Routes. Sometimes this is hidden, but it is definitely there.

 

I tend to spend most of my time looking at Camel documentation when I am working with Routes within Talend. The big benefit of Talend is that you can create Talend jobs and use them with Routes. Other than that, you are essentially working with Camel.

n999
Contributor II
Contributor II
Author

Thanks for that.

Looks like you can run routes as spring boot apps too! 0683p000009MACn.png

Will experiment...hoping to leverage spring boot's use of convention over configuration, with application.properties and application-[profile].properties, to load props for routes. And then use these property files for loading up contexts in jobs using a bespoke tContextLoad job(let)

Cheers for your advise.

ravi999
Contributor III
Contributor III

Hi, 

I have gone through your conversation and the link. We do have a requirement to pass parameters to a rout through a external file or source.

http://edwardost.github.io/cloud/platform/soa/2015/05/14/Working-with-Property-Placeholders-in-Talen...

Couldn't understand in detail the procedure to pass the parameters using property place holders. Do you have any other video or blog with steps in detail?

n999
Contributor II
Contributor II
Author

Hi Richard

This is an oldie but a goodie. 0683p000009MACn.png

I'm only looking at this now(!) and have a quick question please.

 

I've read the post and can understand how you can load all properties(inc talend context props if desired) into the camel context and then refer to them using the camel curly brackets notation.

 

I've got something working that loads props from a file and adds then to the camel context.

 

However in something like a cMQConnectionFactory studio component, the curly brackets cause an error when used in the fields (ie broker uri, username and password). It look like you can only use Talend Context variables in the studio component?

 

Also it doesn't seem possible to override Talend Context variables programmatically (using context.setProperty() ) based on what the talend generated code in readContextValues(contextStr) does.....?

 

Not sure if I'm missing something - Wondering if it's possible to set cMQConnectionFactory and other component values using camel/overridden talend context values or do you have to write camel DSL to create the MQ ConnectionFactory to be able to load in properties?

 

cheers

 

n

 

n999
Contributor II
Contributor II
Author

Hmmm

It does seem possible to update Talend Context Values in a cConfig using the setProperty method by

 

//override context_param value
context_param.setProperty(name, value);
//refresh talend context with context_params
readContextValues(contextStr);

Then context.name has the overridden value...

 

feels a bit brittle......would be interested to know if I'm missing something as per my earlier post today 0683p000009MACn.png

 

 

 

 

 

 

Anonymous
Not applicable

I believe the problem you are experiencing here is ultimately that you cannot change endpoints (or values like that) while a route is running. You can find ways around this by programmatically shutting down the route, making the changes to the variable values and then restarting, but that is about the best you can do. I spent days trying to get around this limitation, but there really is no other way than what I briefly recommended above. If you need to change your cMQConnectionFactory values at runtime, you will need to have another process to take your route down, make the change and then bring the route back up again. It is better to find alternative solutions like having more than 1 route in my opinion

n999
Contributor II
Contributor II
Author

hi - thnx for the reply

 

"If you need to change your cMQConnectionFactory values at runtime,"

 

It's more about *initially* setting them from a file at runtime and in the studio, rather than changing them.

 

The link http://edwardost.github.io/cloud/platform/soa/2015/05/14/Working-with-Property-Placeholders-in-Talen... shows how to add external and Talend Context props to the camel context for use in Talend Components using the {{}} notation.

 

I tried to set the cMQConnectionFactory broker uri usng "{{broker_uri}}" from a successfully populated  camel context but get an error that {{broker_uri}} is not defined. I can get some Talend Components, like cSetBody, to work with "{{broker_uri}}" but not the cMQConnectionFactory....

 

Have you managed to initially set the cMQConnectionFactory component fields with the method from edwardost.github.io?