Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm trying to use a context variable in two places in my job - once in the first subjob, then again in a subsequent subjob (linked with OnSubjobOk). So this should be sequential execution - to avoid any timing issues/race conditions.
And this is driving me insane, because if I write both context and the globalmap variable to console in tJava_2, I get values. But in tJava_1 (earlier) they are null, AND in the tFileDelete (which is order: 1, after tJava_2) it's also null.
It doesn't make any sense. Isn't OnSubjobOk supposed to be sequential? I'm also using globalMap to be thread safe. What's happening?
Restarted Studio, reset context - now it works..
Here is the log showing the values, and the tJavaFlex_1 where I set the globalMap variable I'm also trying to use.
Restarted Studio, reset context - now it works..
I’ve run into the same issue before — it can be really confusing because even though OnSubjobOk guarantees sequential execution, context variables in Talend don’t automatically propagate back if you overwrite them in a subjob.
A couple of things that helped me:
Make sure you’re updating the context variable itself, not just assigning a local copy in tJava. For example: context.myVar = globalMap.get("myVar");
Use globalMap consistently to pass values between subjobs; then explicitly assign them back to context if needed at the start of the next subjob.
Double-check the execution order in the job designer — sometimes a tRunJob or parallel branch can run unexpectedly if not carefully connected.
Basically, treat globalMap as the “shared memory” and context as your configuration snapshot. That usually fixes the null problem in subsequent subjobs.
It’s tricky, but once you set the assignment pattern consistently, the values survive between subjobs.