Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
DBLONDEL1643728674
Contributor III
Contributor III

How to stop a Talend job after x seconds ?

Bonjour,

Working with Talend Cloud Data Integration 7.3 we sometimes have issues with tpop or tsendmail components never ending.

As the job is running every 15 minutes, when the previous run is not finished, it stops the new runs after 20 minutes...

I am trying to find a standard "option" in talend studio or in talend TMC (like a timeout) to stop a job after x minutes.

I am experimenting, without success, running 2 subjobs in parallele , one containing a tdie after 60 seconds tSleep; the second one containing a loop with no end ... I was expecting the job to stop after 60 seconds, but it continues to run ...

Do you have any idea ?

0695b00000HtgTDAAZ.png

Labels (2)
1 Reply
Anonymous
Not applicable

Hmmm, this seems odd that those components are not ending and are not erroring. I would recommend you speak to support about that issue.

 

However, I do have a workaround for you. I have tested it in a simple job as shown below.....

0695b00000HtrWwAAJ.png 

I am using a tParallelize component to handle this. The tParallelize is set up as below....

0695b00000HtrRhAAJ.pngNotice that the "Die when one of the parallelize subjobs fails" is ticked.

 

The tJava (SendMail Emulation) is just my emulation of your tPop or tSendMail. This counts to 100 in seconds. The code for this is shown below incase you want to try it....

 

for(int i=0; i<100; i++){

Thread.sleep(1000);

System.out.println(i);

}

 

The tJava (Set end variable) is only called once the previous component has finished processing. This sets a globalMap variable to say it is done. The code for that is below....

 

globalMap.put("finished", true);

 

The tJava (Timeout code) is used to limit the time to 20 seconds in this case. The code for this can be seen below....

 

for(int i=0; i<20; i++){

Thread.sleep(1000);

if(globalMap.get("finished")!=null){

i = 20;

}

}

 

It checks the value held by the globalMap "finished" key to see whether the email processing is complete. If it is, it stops this timer so that your job will finish. If it gets to the end of the for loop without that variable changing, it ends and the following RunIf link logic is triggered.

 

The RunIf logic is as below....

 

globalMap.get("finished")==null

 

If the "finished" value is null, it means that the mail processing has not finished. It therefore calls the next component which is a tDie. If the value is not null, then the mail has finished and the tDie is not called.

 

The tDie is configured as below. You can add whatever error message you wish....

0695b00000HtrZRAAZ.png 

This should solve your issue. However, as I said, I would contact support and speak to them about the issue with the components not finishing.