Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I am developping a little java application that can run a job depending on some conditions.
All I want is to know inside my java code if the job run successfully or not.
Here is my code :
job_launcher talendJob = new job_launcher();
String [] context = new String[] {"--context_param row_id="+customMessage.toString()};
String[][] code = talendJob.runJob(context);
for(String[] s : code){
for(String s2 : s){
log.info(s2);
}
}
The problem is that the returning code is always 0, even if my job throws a null pointer exception or something else.
So how can I proceed to determine if my job failed ?
Thanks,
Guillaume
Hi,
Since you are using the main class, it is giving the exit condition as 0.
Could you please try below code snippet?
String[] args = {};
local_project.helloworld_0_1.helloworld obj1 = new local_project.helloworld_0_1.helloworld();
int exitCode = obj1.runJobInTOS(args);
if (exitCode != 0)
{
throw new NullPointerException("Demo exception - Child job failed !!!! ");
}
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂