How to Close a Job in an infinite loop?

One Star

How to Close a Job in an infinite loop?

Hi to all
Can anyone, please, tell me how to close the job in an infinite loop. I have a job which starts with tRunJob component. On subjob error, backup routine is being executed (archiving some files, and sending them via email). I need a solution that would allow me, after backup routine execution, to run job again from the beginning.
I tried to make another TOS job, containing only tRunJob component that's calling the main job, but then I realised that it's a recursion, and that it's not looping, but making new instances of jobs, so eventually, I would get out of memory.
I tried also to loop main job with tInfiniteLoop, but it doesn't help me at all, because, after executing backup routine, program terminates.
Employee

Re: How to Close a Job in an infinite loop?

Hello,

Two way :
1) use a tDie, tRunjob->OnSubjobOk->tDie with errorCode=0 and exit JVM immediately
2) use the tLoop insted of tInfiniteLoop.
a) create a boolean global var
in the tLoop, select loop type =while
set Declaration = globalMap.put("MyVar",true)
set Condition = (Boolean)globalMap.get("MyVar")
set Iteration = ""
-> you have a infinite loop

b) exit condition
use a tSetGlobalVar component
tRunjob -> OnSubjobOk -> tSetGlobalVar
set MyVar to false
-> you have a exit condition
One Star

Re: How to Close a Job in an infinite loop?

Thanks a lot for the swift answer, emenuet.
I think you didn't understand my problem. However, just in case, I tried both of your suggestions.
Scenario 1
I already have exit condition for job that is being executed by tRunJob component, I'm managing it in tJavaRow component and it works.
Scenario 2
I liked this idea very much, and I immediately tried this out, but, TOS doesn't allow me to iterate on tRunJob, It displays an error "A component that is not a sub process start can not have any link on sub job ok / on sub job error in input". I tried moving backup routine to main job, and leaving only tLoop and tRunJob, but I got the same results as from my original design.
Let me explain you problem once more. I need application NOT TO terminate after throwing the exception. tRunJob is executing another job that waits for files to be created in an folder, and then my Java code uploads that code, and archive it. However, if ftp server is not available, or some other error occurs, those files must be sent via email. The first thing is working just fine (ftp upload), but, if error occurs, files are being sent via email and then job terminates. I do not want it to terminate, I want it to run from the beginning (to run ftp job again)
Here are the screenshots, I hope these will be helpful.
Employee

Re: How to Close a Job in an infinite loop?

Hello,
In your tRunjob, in basic setting panel, you should uncheck "Die on Child Error", now your job is still alive even if FTP connection failed.
use Run If Link trigger rather than OnComponentOK or OnComponentERROR. the tRunJob will be always OK.
In run if condition, use global variable tRunJob_1_CHILD_RETURN_CODE to test return code. 0, it's OK, 1 it's failed.

FYI: Only Start Component can have OnSubjob link
One Star

Re: How to Close a Job in an infinite loop?

Done, I've got the same result.
tRunJob is executing until exception occurance. Then backup routine is executed (tFileArchive, tSendMail, tJava, tFileDelete), and then program terminates normally (after tFileDelete). I actually get exit code 0. I need to avoid this. Instead of terminating program after successful backup routine execution, I need it to be ran again. Main job (the one with tRunJob) should NEVER terminate (only execute backup routine in case of ftp problem, and then run itself again)
I'm sorry if I'm repeating myself, but I have feeling that I didn't explain problem clearly so you couldn't understand me.
One Star

Re: How to Close a Job in an infinite loop?

Hi
You have got answer already in prevous post:
In run if condition, use global variable tRunJob_1_CHILD_RETURN_CODE to test return code. 0, it's OK, 1 it's failed.

Try to use this process:
tLoop( tRunJob_1_CHILD_RETURN_CODE condition)->TRunJob1 (Die on error flag should be disable)
I have using this working scenario for few years.
Good Luck.

Re: How to Close a Job in an infinite loop?

Hi,
I want to archive folders based on its name using talend component.
anyone have any idea,How to do these..