Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
AWS Degraded - You may experience Community slowness, timeouts, or trouble accessing: LATEST HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] How to get the error message from the child job

Dear Helpers,
We have a parent job with a tRunJob component. Both jobs have tLogCatcher inside. Inside the
child job execeptions/errors via tDie can occur. How can the error message passed to the parent
job that calls the sub-job via tRunJob? Are there any globalMap parameters or what approach is
applied for that?
I have found that entry
https://community.talend.com/t5/Design-and-Development/how-to-catch-the-error-message-of-sub-job-at-...
but it doesn't work.
I am very grateful for any help.
Kind regards
Hilderich
Labels (2)
16 Replies
Anonymous
Not applicable
Author

Hello sanvaibhav,
I cannot grasp why a context variable of type String doesn't work (also not working with
option "transmit whole context" in tRunJob) but it works when this context variable is of
type Object and you assign a HashMap to it in parent and modify its entries in the child
jobs. Then theses values are in a bi-directional access for parent and child afterwards.
That's magic.
tJavaRow (parent)
Map<String,String> errors = new HashMap<String,String>();
errors.put("ERRORS","");
context.errors = errors;
tRunJob (parent) with option "Transmit whole context"
tLogCatcher -> tJavaRow (child)
Map<String,String> errors = (HashMap<String,String>) context.errors;
errors.put("ERRORS", output_row.message);
tLogCatcher -> tJavaRow (parent)
Map<String,String> errors = (HashMap<String,String>) context.errors;
if(StringUtils.isNotBlank(errors.get("ERRORS"))) {
output_row.message = errors.get("ERRORS");
}
Conclusion: That works!
Kind regards
Hilderich
willm1
Creator
Creator

I cannot grasp why a context variable of type String doesn't work (also not working with
option "transmit whole context" in tRunJob) but it works when this context variable is of
type Object and you assign a HashMap to it in parent and modify its entries in the child
jobs. Then theses values are in a bi-directional access for parent and child afterwards.
That's magic.

The key to understanding Talend parameter passing, is to understand how Java handles parameter passing. When you pass your Context variables to a child Job (or return values back), you are using the Java parameter passing mechanism. Java Passes by Value. This means that when you transmit your context variables to your child Job, you can't simply reassign the value, for the parent Job to then pick it up.
By passing in a hashmap (mutable object) to the child job in a context, the child job changes it and that hashmap returns the value in the parent that was changed in the child...
See this article for the more complete explanation... http://www.talendbyexample.com/talend-returning-values-from-subjobs.html Scroll down to the section that starts with "Returning Values through Context"
_AnonymousUser
Specialist III
Specialist III

The simple truth is that you just will post ads for babysitting jobs online and offer up your babysitting services through bulletin boards and web portals and job hunting sites. The trick is to be careful-especially if you are under age. Always have a parent go with you to meet your potential babysitter job clients before the actual job is to take place.
https://junglejuniors.com.au/
Anonymous
Not applicable
Author

Hi  Hilderich
Using a tBufferOutput component in the child job to pass the error message from the child job to the main job. Refer to this KB article:
https://help.talend.com/search/all?query=Returning+a+value+from+a+child+Job+to+the+parent+Job&conten...
Shong
tBufferOutput is not working in this case Shong.
need a solution
Anonymous
Not applicable
Author

tBufferOutput is not working in this case Shong.
need a solution...
_AnonymousUser
Specialist III
Specialist III

Exactly Satya!
Shong, 
As Satya said, tBufferOutput doesn't work during error. I mean, it doesn't carry information from child to parent incase of error.
But the same component is successfully carrying data incase of job success. Please take an example and try it....
Regards,
Vijay (abhicool666@gmail.com)
Anonymous
Not applicable
Author

Hi Vijay
I gave an example in my reply in this the article that use onsubjoberror to trigger a subjob that pass the customized message from the child job to parent job, i have tested it and it works.
Best regards
Shong