One Star

Abort the job with different error message

Hi,
I have a job which reads an input file and updates the fields in salesforce object. The job is working fine and I would like to add some error handling conditions. The following two requirements are mandatory.
If the input file is not available, the job should abort with the error message "Input File not found. Aborting..".
If the input file is available, then the first two characters in the first record (batch header record) must be "01". If it is not "01", the job should abort with the error message "Input file not set for the division Corporate Sales".
I know I can use tlogCatcher and tDie, but not sure how to handle these two cases. I may have to add more error condition later.
Can some one help me?
Thanks,
Balaji.
7 REPLIES

Re: Abort the job with different error message

if you have a parent job calling this job you mentioned
you could raise the error
and in your parent job you can check your error output value and DO something.
does it help?
Nicolas
One Star

Re: Abort the job with different error message

Thanks for your response.
There is no parent-child job concept here. This is just a single job and I need to abort the job based on different error conditions.
Thanks,
Balaji.
One Star

Re: Abort the job with different error message

No other replies on this post? I am still waiting for some one to help..
Thanks,
Balaji.
One Star

Re: Abort the job with different error message

Ok. I figured it out. The job is as below.
tFileInputFullRow ==> tSampleRow ==> tJavaRow
tSampleRow has the range as "1..1" and tJavaRow has the code below.
if (!("01".equals(input_row.line.substring(0,2))))
{
throw new Exception("\n File is not for production Aborting..");
}
The job has a tlogRow and tDie component. The job is throwing the exception and tlogCatcher is catching. But the job is not aborting.
The job seems to be running in an infinite loop and I see the output below.

Starting job test at 11:19 23/03/2012.
connecting to socket on port 4023
Exception in component tJavaRow_2
java.lang.Exception:
File is not for production Aborting..
at omsleodev.test_0_1.test.tFileInputFullRow_1Process(test.java:690)
at omsleodev.test_0_1.test.runJobInTOS(test.java:1426)
at omsleodev.test_0_1.test.main(test.java:1294)
connected
disconnected
disconnected
disconnected
disconnected
disconnected
disconnected
disconnected
disconnected
disconnected
disconnected
disconnected
.
.
.
.
.
disconnected
disconnected
disconnected
disconnected
disconnected
Exception in thread "main" java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error:
.
.
.
.
.
.
java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.Error: java.lang.StackOverflowError
Job test ended at 11:19 23/03/2012.

I had to manually kill the job.
How do I make the job to abort automatically in case of the exception? Setting the "Exit JVM immediately" in the tDie component is not working in this case.
Thanks,
Balaji.
One Star

Re: Abort the job with different error message

You can pass an on error condition to a tDie and customise the message.
One Star

Re: Abort the job with different error message

Thanks for your response.
More than customizing the message, I am interested in "ABORTING" the job.
Thanks,
Balaji.
One Star

Re: Abort the job with different error message

I found it. I had to uncheck the "Catch tDie" checkbox for the tlogCatcher component.
However, with out this, it appears to be a bug in talend.
Thanks,
Balaji.