Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Raise Exception in Tjava

Hi

I am trying to raise an exception (Fail the job) within a tJava component, and want to know if this is possible.

 

I understand a solution to this would be to have a If statement connection to a tDie, however i am trying to get the below working.

 

context.Count1=Integer.parseInt(((String)globalMap.get("total")));
System.out.println(context.Count1);
context.Count2=(((Integer)globalMap.get("tFileRowCount_1_COUNT"))-1);
System.out.println(context.Count2);
if (context.Count2.equals(context.Count1))
{
System.out.println("The number's match");
}
else
{
System.out.println("The number's don't match");

throw new Exception;
}

 

Is this possible? To raise throw an exception inside of the Java code?

 

Thank you

 

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hello,

You can use tJava component to make the if else statement exit the job.

Here is a related topic:https://community.talend.com/t5/Design-and-Development/tJava-IF-ELSE-statement-fails/m-p/38949

Let us know if it is OK with you.

Best regards

Sabrina

View solution in original post

4 Replies
Anonymous
Not applicable
Author

Hello,

You can use tJava component to make the if else statement exit the job.

Here is a related topic:https://community.talend.com/t5/Design-and-Development/tJava-IF-ELSE-statement-fails/m-p/38949

Let us know if it is OK with you.

Best regards

Sabrina

talendtester
Creator III
Creator III

Is it not possible to force the end of a subjob in a tJava without exiting the entire job?

My goal is to have the rest of the job run even if some of the subjobs have errors.

Anonymous
Not applicable
Author

@talendtester, move the subjob to child job and call it with tRunJob, uncheck the 'die on error' option. With this job design, the main job will continue to execute even though the child job has error.
talendtester
Creator III
Creator III

@shongYou are saying I need to save each subjob as its own job? So I will end up having 20 different jobs?

 

Why doesn't Talend add a function similar to System.Exit that only breaks out of the current subjob? Something like System.SubExit