Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Get exit code of a job run from an external java application

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

 

 

Labels (3)
1 Reply
Anonymous
Not applicable
Author

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 🙂