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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Alpha549
Creator II
Creator II

Go to a specific component (go to the tPostjob part of the job) before exiting the job

Hello everyone,

I'm in this job situation :

I have a tPostjob. In this tPostJob flow, I do several things like sending an e-mail listing errors that happened during the job. I can declare an error using a tWarn with the code 1. So this is not really a fatal error.

There is a case in my job when I manually end the job, using a tJava with the instruction System.exit(1); I don't use tDie component because I can't get the real exit code in the parent job. This works well with System.exit though. I indeed need a specific return code, which is not 1. tDie component makes the exit code be 1 even if I set another value...

The job is brutally stopped. However, I would like to execute the tPostJob flow before exiting the job.

Do you have an idea ?

I thought about using a on component ok to go directly to the first component of my tpostjob flow, and then run the System.exit(1); instruction using an if type flow. This could work but do you have another way ?

Thank you !

Labels (2)
1 Solution

Accepted Solutions
gjeremy1617088143

HI @Alpha549 Alpha549​ ,

you can use tPostjob_1Process(globalMap) to call directly the postjob component

at the end of the postjob subjob add System.exit(1);

to ensure that it will not be executed 1 more time.

 

I've made a simple job to test it :

tjava with

System.out.prinln("1");

-->on component ok -->

tjava with

System.out.prinln("2");

tPostjob_1Process(globalMap);

-->on component ok -->

tjava with

System.out.prinln("3");

 

tPostjob

-->oncomponent ok -->

tjava with

System.out.prinln("4");

System.exit(1);

 

result :

1

2

4

 

if you don't add the system exit at the end :

 

result :

1

2

4

3

4

Send me Love and KUdos

View solution in original post

7 Replies
Anonymous
Not applicable

Hi

The components linked by tPostJob always executes even though there is an error, don't need to use OnComponentOK trigger. Not sure why you use If type flow, if you want to customize the exit code based on the execution status of subjobs, you can use context variable as the return code, eg:

bababa

-onSubjobOK--tJava1

-onSubjobError--tJava2

tPostJob--oncomponentok--baba...oncomponentok->tJava3

 

tJava1:

context.returnCode=1;

tJava2:

context.returnCode=-1;

tJava3:

System.exit(context.returnCode);

 

Regards

Shong

 

 

 

gjeremy1617088143

HI @Alpha549 Alpha549​ ,

you can use tPostjob_1Process(globalMap) to call directly the postjob component

at the end of the postjob subjob add System.exit(1);

to ensure that it will not be executed 1 more time.

 

I've made a simple job to test it :

tjava with

System.out.prinln("1");

-->on component ok -->

tjava with

System.out.prinln("2");

tPostjob_1Process(globalMap);

-->on component ok -->

tjava with

System.out.prinln("3");

 

tPostjob

-->oncomponent ok -->

tjava with

System.out.prinln("4");

System.exit(1);

 

result :

1

2

4

 

if you don't add the system exit at the end :

 

result :

1

2

4

3

4

Send me Love and KUdos

Alpha549
Creator II
Creator II
Author

Oh wooooow, I didn't know a function like this existed. How did you find it ?

Are there other functions like this ?

 

It perfectly answers my question, thanks a lot !

gjeremy1617088143

you're welcome 🙂

I dug in the java code of the component to see how it work,

the Process function work for all component it's funny to play with

Alpha549
Creator II
Creator II
Author

How did you display the code of the component ?

gjeremy1617088143

I go to the code view,

you could also click on a component then ctrl +G it will onpen the code view at the line of your component process code.

Alpha549
Creator II
Creator II
Author

Perfect ! Thanks a lot again.

Question solved 🙂