Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
tRunJob has a checkbox "Transmit whole context". I think that this is what you're looking for.
What tal00000 suggested is right, but I think you are using the context variables slightly wrong. First we have to describe the contexts so that we are all on the same page (Talend do a really bad job of this).
Context Variables are the actual variables. A Context Variable can have a different value per Context (DEV, UAT, TEST, PROD, etc). A Context Group is just a grouping of Context Variables that can have multiple Contexts (.....the names could be so much better).
The problem you have is that you cannot dynamically change the Context of a job at runtime. These should only really used to separate environments. What you can do is ensure that you parent job holds all of the context variables that your child will use and use the "Transmit whole context" option on the child job. This will ensure that the values you pass to your child job will correspond to those in your parent job. No matter what is in your context variables in the your child job, if a context variable value is passed in, it will overwrite whatever is set as a default.
I would recommend completely forgetting about Contexts and only having 1 (default). Clear all context variable values and store the values in a file or database. Then use either a tContextLoad to read in the context variable values from a file or a database table or use the implicit context load. This method gives you far more control.
Example:
We have 3 contexts, Dev, QA, and Prod, plus Default which has the same settings as Dev, and several context groups (Files, SQL_Server, PB_Server, Master_Server, etc.) and with the context group SQL_Server, there is a variable 'SQL_SERVER_ServerName', that depending on context could have values : Default/Dev: devnymssql02, QA: qanymssql02, Prod: mcgnymssql02
Parent job is running with a context of 'QA', and contains a tRunjob widget launching Child job with 'transmit whole context' set and context of 'Default' selected.
In Parent job, contextStr is 'QA', and SQL_SERVER_ServerName is 'qanymssql02'
In Child job, contextStr is 'Default' (this is why we didn't think things were working), but SQL_SERVER_ServerName is 'qanymssql02' as hoped/expected.
So: with 'transmit whole context' selected, the proper context values are being delivered to the child, but the contextStr within the child does not accurately reflect that.
Hi jds, I'm not sure I understand you issue here. You said....
...
In Child job, contextStr is 'Default' (this is why we didn't think things were working), but SQL_SERVER_ServerName is 'qanymssql02' as hoped/expected.
So: with 'transmit whole context' selected, the proper context values are being delivered to the child, but the contextStr within the child does not accurately reflect that.
This suggests that it is working. Your value for contextStr in the Child job is "as hoped/expected". What exactly do you think is the issue?
Sorry, I'm not meaning to be difficult, I just don't see the problem and you may well have one that I am not getting.
With regard to identifying whether a job is parent or child, that is pretty easy. All Talend jobs have public variables called "fatherPid" and "pid" (amongst others, but they aren't important here). If the fatherPid holds the same value as the pid, then the job is a parent. If they are different, then the job is a child.
5-years ... but the same issue.
Because trunjob by using it as "dynamic" job allows and "asks" for variables:
I have an example of a ParentJob with 2 Children. Parent und Children have the same ContextGroups: prod and dev
... and I give the name of the used contextgroup to a context-variable named "enviroment".
Using a dynamic job in trunjob ... I can select the context.enviroment. But the children will run with the default contextgroup but not with the contextgroup given in context.enviroment.
Who is wrong?
Hi, have checked Transmit whole context ?
you can also put your context.environment var into a globalMap
then call the globalMap instead context ont the Context field of the trunjob
In tJava_1
globalMap.put("env",context.environment);
in Context field of trunjob :
(String)globalMap.get("env")
Send me Love and kudos