Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Donatien1
Partner - Contributor III
Partner - Contributor III

How to change context value from a job which is deployed with a route?

Hello everyone,

 

I have developed a route which call a job with a cTalendJob componant.

The job use some context values.

 

When I deploy my route, I'm able to update my context used by the route but not the one used by the job.

The only way I found for the moment is to update the value on the studio and deploy the project again (to me it's not a good way to do).

 

Is there other way to do?

 

Regards.

Donatien

Labels (2)
7 Replies
Anonymous
Not applicable

Don't use Contexts in Routes. Due to the fact that Routes are always on, it doesn't make sense to think of the Route in a "batch" way. You should think about the Exchange (the message) as a "batch within the Route". As such, you should use Exchange Headers in the way you use Contexts. 

Donatien1
Partner - Contributor III
Partner - Contributor III
Author

Hello rhall_2_0,

 

Not sure to understand what you mean with "Don't use Contexts in Routes"...

I got a JMS receiver to get my messages, so I need to have a context so set my JMS configuration.

 

After, I need to get some data from a database, so I call a job to get those data. My job context contains the database configuration. 

So you recommend me to send values to the job with exchange headers and not to use job context? But I need route context for this configuration too.

 

Anonymous
Not applicable

Sorry, I should have been clearer. You can use Context variables for values which will be fixed for the lifespan of the Route. That is fine. However, if you want to be able to change values depending on the data that flows through the route, you will need to use Headers. I got the impression you were trying to do change the values during the lifespan of the route.

 

If your values will be set for the lifespan of the route, you should be able to use the Context Param section of the cTalendJob. Is this not working?

Donatien1
Partner - Contributor III
Partner - Contributor III
Author

Ok rhall_2_0, I got the same opinion.

My contexts were used only for connections to JMS server or database connection, those values were fixed for the lifespan.

 

My problem was : the database server was migrated and I need to change the configuration of my context job.

My question was : what is the procedure to update my job context (which is called by a cTalendJob from a route)?

I know that I will stop my project to update the configuration, but on the route configuration there is no reference of the job context.

 

Anonymous
Not applicable

OK, I see. If you have Contexts that are being shared with from a Route to a cTalendJob they must be available in the Route. My assumption is that you are trying to change these in the TAC configuration and the Contexts do not appear. This will be because they only exist in the cTalendJob. I assume (sorry, lots of assumptions) that you compiled your route and job with some default context values that work for the job. This is why it has previously worked.

 

While we are at this point, it is probably worth pointing out that you can use connection pooling inside Apache Karaf and use the "Specify a data source alias" to set databases in cTalendJobs to be set from that. That is far more efficient and a lot easier to control (once it is configured...which can be a pain the first time). Take a look here (https://community.talend.com/t5/Design-and-Development/setting-up-JDBC-connection-pool-in-Talend-ESB...) and here (https://community.talend.com/t5/Design-and-Development/Connection-pooling/td-p/114417) for some ideas

Donatien1
Partner - Contributor III
Partner - Contributor III
Author

Thank you rhall_2_0.

 

How did you do if you have other data on contexts, like file system access or JMS connection?

The database is only one different element I connect from my jobs.

Anonymous
Not applicable

You can still use Contexts for this, but databases are just easier to configure using connection pools. I believe the same can be done with "connection factory JNDI name" for JMS connections.

 

Basically when it comes to contexts in DI Jobs you have much more flexibility. You can change the values during the lifespan of the Job. Within Routes you are restricted in this. You CAN still use them when the values aren't expected to change, but if you have values changing per Exchange, it is best to find another way of working (Headers for example).