Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
JackStrong
Contributor II
Contributor II

How to exit from child job and continue processing in parent job

Hi All.

Because I have some issue regarding tSendMail component (from time to time tSendMail hangs and child job doesn't go further; there is no fail/exception, nothing), so I need to implement workaround to continue parent job to complete remaining logic in the parent job.

tSendMail component is the last one in my child job.

I am thinking about changing my logic in child job in this way.

Here is what I have right now (but this is not good solution because sometime tSendMail hangs):

(child job)

.... ---(OnSubjobOk)---> tSendMail

---(OnSubjobOk)--->...

And here what I am thinking about (improvement):

.... ---(OnSubjobOk) ---> tParallelize (end of first subjob)

---(Parallelize1)---> tSleep (20 secs)

---(Parallelize2)---> tSendMail

---(Synchronize (Wait for first)) ---> tJava (???)

My question is: what can I put into tJava(???) to stop/skip processing child job (tSendMail is the last component in the child job) and continue parent job?

What I want to achieve is that in case of tSendMail hanging, tJava code will be executed after sleeping 20 seconds and then we should exit from child job and hand over control to parent job.

Or maybe you have some different idea how to manage this issue.

I am running the jobs in Studio and TMC.

Thanks in advance!

Best regards.

Labels (2)
5 Replies
Anonymous
Not applicable

Hi

Use a tDie component to kill the child job and exit the JVM if tSendMail hangs for more than 20 seconds, for example:

...

onsubjobok

|

tParallelize--(Parallelize1)--tSleep(20 secs)--runIf--tDie

--(Parallelize1)--tSendMail--oncomponent--tJava

 

Define a context variable called "isDie", boolean type, set the default value as true;

if tSendmail ends normally, set the value of context variable to false on tJava;

context.isDie=false;

 

 set the condition of runIf with context variable: context.isDie

on tDie, you can customize the error messages and error code, check the 'Exit the JVM immediately" box in the advanced settings panel.

 

In parent job, use a tRunJob to call the child job.

on tRunJob:

Check the 'use an independent process to run subjob' box.

Uncheck the 'Die on child job' box to continue parent job even though child job has an error.

 

Regards

Shong

 

 

 

 

 

 

JackStrong
Contributor II
Contributor II
Author

Hi shong.

 

Thanks for your proposal and explanation.

 

I am afraid I can't uncheck the "Die on child job" on tRun. I need this in case of other issues during processing child job. There can be different issues when child job is running and this is why I added joblet with tLogCatcher inside to catch errors. In case of other issues than tSendMail hanging my child and parent jobs need to be stop.

Do you think is it possible to stop child job in different way without unchecking "Die on child job" and without checking "use an independent process to run subjob'"?

 

Till now I observed tSendMail was hanging only in DEV and TEST, but recently it has appeared few times in PROD too. So I have to find some way how to manage this. Problem is that I don't have any idea why the issues occures.

Admin team was not able to find nothing in logs. Probably there is some gap in the tSendMail component.

 

Best regards.

JackStrong
Contributor II
Contributor II
Author

I added custom properties to tSendMail component (Advanced settings):

"mail.smtp.timeout"

"mail.smtp.connectiontimeout"

"mail.smtp.writetimeout"

I don't know if this will help. I didn't have the opportunity to test it. I will check in the future and let you know about the result.

I hope in case of tSendMail hanging the timeout feature will work and job will fail.

 

Regards.

JackStrong
Contributor II
Contributor II
Author

Hi.

 

I decided to stay with solution where child job and parent job are forced to fail when it takes too much time to send mail. I was not able to find any solution to continue parent job without checking the 'use an independent process to run subjob' box.

 

@Shicong Hong​ your proposal (tParallelize + tSleep + tDie) is ok. The only disadvantage is that every time job is waiting (tSleep component) even when tSendMail is completed in few secs.

This is why I will stay with solution which includes custom properties:

"mail.smtp.timeout"

"mail.smtp.connectiontimeout"

"mail.smtp.writetimeout"

 

After 1 month I see that mentioned above properties works fine and e.g. in case of issues regarding receiving response from smtp server, the child job fails after 20 secs.

 

Best regards.

Anonymous
Not applicable

@Michal Swiniarski​ , thanks for sharing the solution and giving the feedback. I have never had a chance to test the timeout parameter, it seems like it is the best solution to tSendMail hanging problem.