• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » Same context variables in multiple subjobs with tParallelize

#1 2012-06-15 04:45:40

pnbalaji
Member
Registered: 2012-02-14
Posts: 53

Same context variables in multiple subjobs with tParallelize

Hi,

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?

Thanks,
Balaji.

Offline

#2 2012-06-15 06:27:15

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: Same context variables in multiple subjobs with tParallelize

Hi Balaji

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].

Regards,
Pedro


Only Paranoid Survive.

Offline

#3 2012-06-15 15:08:11

pnbalaji
Member
Registered: 2012-02-14
Posts: 53

Re: Same context variables in multiple subjobs with tParallelize

Hi Pedro,

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)?

Thanks,
Balaji.

Offline

#4 2012-06-18 03:46:47

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: Same context variables in multiple subjobs with tParallelize

Hi Balaji

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.

Regards,
Pedro


Only Paranoid Survive.

Offline

#5 2012-06-18 04:39:48

pnbalaji
Member
Registered: 2012-02-14
Posts: 53

Re: Same context variables in multiple subjobs with tParallelize

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.

Thanks,
Balaji.

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » Same context variables in multiple subjobs with tParallelize

Board footer

Powered by FluxBB