You are not logged in.
I am using TIS 4.2.4 and I have a talend job which consists of multiple subjobs. I am using a boolean context variable called context.sendL3 and this context variable is used in all subjobs. All the subjobs are executed in parallel using tParallelize component. Will this have any unexpected behaviour.
Each subjob does the following.
1. Reads an input file.
2. Initializes the context.sendL3 as false first.
3. Based on the data from input file, sets the context.sendL3 as true.
4. Based on value of context.sendL3, a temporary output file is created with specific data.
5. Finally all the temporary output files are merged with a tFileOutputMSPositional component to create a multi-schema layout file.
Is it okay to use the same context variable (context.sendL3) in all subjobs when they are executed in parallel?
In theory, it won't cause any unexpected behavior.
Please notice the execution order of all these subjobs and 'Wait for' condition.
For more information, you might read the instructions and scenarios in the document [TalendEnterprise_Component_RG_50b_EN].
Thanks for the reply.
My original understanding was that context variables are similar to static variables in java. So, once a context variable is updated in a job, it can be used anywhere else in the job. Is it not so? Do they have a scope (scope with in a subjob)?
Although context variable is not static variable, it is used anywhere else in the job.
One subjob updates this context variable. Another subjob will get this new value.
Yes, I did verify this with a small test job with having 5 subjobs.
The job has a context variable called count which is initialized to 0. Each subjob has a tSleep component, each with different seconds setting and the onSubjobOk from the tSleep goes to a tJava. The tJava component increments the context.count variable and prints it on the console.
I could see that the updated value of the context variable is passed to other subjobs.