How to Use tPrejob and tPostJob

Highlighted
Moderator

How to Use tPrejob and tPostJob

tPrejob and tPostjob are great when you need execute given tasks, before and after your job. Unlike other components, these components do not process data and cannot be configured. They always execute, even if the main job fails, making them great for tasks that need to be completed even if the job is not successful.

 

Some scenarios in which you might need to use tPrejob include:

  • loading context information
  • logging the start of the job
  • ensuring that a file exists
  • creating a database connection

On the other hand, you might use tPostjob to:

  • delete any temporary files you created within the job
  • log the end of a job
  • close any connections that you may have created

These components are added to jobs the same way any other components are, simply click and drag them from the palette or search for them by clicking on the canvas. All you need to do after that is connect them to your subjob using an “OnComponentOk” connection. Bellow, is an example of tPrejob and tPostjob being utilized.

 

picc1.png

Highlighted
Moderator

Re: How to Use tPrejob and tPostJob

Hello,

Thanks for sharing it with us.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Highlighted
Four Stars

Re: How to Use tPrejob and tPostJob

Thanks for the post/information.

Just to be absolutely clear, the screen shot shown is BEFORE the OnComponentOk connections to the subjob have been added? The subjob being the employee to tMap to tFileOutputDelimited?

Or is the screen shot the "final" product?

 

Highlighted
Eight Stars

Re: How to Use tPrejob and tPostJob

Hello CygnusX1,

 

the screenshot shows the final job design. There is no connection from PreJob to the main subjob or from there to PostJob. The "employee" component has a green background, that means it is the start component of the main subjob (executed after PreJob and before PostJob).

 

Best regards,

 

Thomas

 

Highlighted
One Star

Re: How to Use tPrejob and tPostJob

A description of the error. This variable is cleared upon entering a step, and is set when an error occurs during step operation. This variable can only be used in the next step condition. The ErrorDescription is also saved in the C.sys.LastErrorDescription and this value is not cleared. For more information about this variable and embarkdaily embarkup

Highlighted
Two Stars

Re: How to Use tPrejob and tPostJob

wow! looks great, thank you for sharing!
I've found just this http://umashanthan.blogspot.com/2016/01/when-or-how-to-use-tprejob-and-tpostjob.htmllink and it was cool to see one more example of this. for me, as a freelance writer working on different educational projects that's really important

Highlighted
Two Stars

Re: How to Use tPrejob and tPostJob

wow! looks great, thank you for sharing!
I've found just this http://umashanthan.blogspot.com/2016/01/when-or-how-to-use-tprejob-and-tpostjob.htmllink and it was cool to see one more example of this. for me, as a freelance writer working on different educational projects that's really important

Highlighted
Two Stars

Re: How to Use tPrejob and tPostJob

wow! looks great, thank you for sharing!
I've found just this http://umashanthan.blogspot.com/2016/01/when-or-how-to-use-tprejob-and-tpostjob.html and it was cool to see one more example of this. for me, as a freelance writer working on different educational projects that's really important

Highlighted
Five Stars

Re: How to Use tPrejob and tPostJob

If you want to use these components, I think it is necessary to check the state of the prejob before starting main. And this is especially necessary in the case of a base extraction in the middle of a job that lasts one hour. Smiley Happy

 

The control can be simple, something like this for example:

 

prejob_example.png

 

Highlighted
Nine Stars

Re: How to Use tPrejob and tPostJob

Hi,
Great post, however, I'm not a huge fan of using tPreJob for DB connection: if the connection fails, the job will continue unnecessarily (worse, it might even start to do something that will have to be reverted later).
tPreJob should really be used with care perfectly knowing that it won't stop the job if it fails!
The tPostJob on the other hand is really usefull.
Regards.
Highlighted
Seven Stars

Re: How to Use tPrejob and tPostJob

And the Advanced settings of tDie : Exit JVM immediately ? tPrejob_1 -> tPostgresqlConnection_1 --[OnSubjobError]--> tDie  

Highlighted
Five Stars

Re: How to Use tPrejob and tPostJob

Hi, i've got a problem with the Postjob execution

 

In my simple test case here :

Capture.PNG

What i expect : Tdie Error then Only execute the Postjob part

 

Try 1 => tDie advanced option set with checked "Exit the JVM immediately"

What i got = Tdie Error and no Postjob execution

 

Try 2 => tDie advanced option set with unchecked "Exit the JVM immediately"

What i got = Tdie Error and Main Part execution and Postjob execution

 

The only solution i found to have what i expect is using a empty tJava with if link on the tDie CODE:

Capture.PNG

 

So the tPostjob isnt working in any case ?

Highlighted
Seven Stars

Re: How to Use tPrejob and tPostJob

What i expect : Tdie Error then Only execute the Postjob part
??? why you dont add preJobMessagePrint in Prejob and finishing by tDie (and checked stop JVM immediately) ? more simple
Highlighted
Five Stars

Re: How to Use tPrejob and tPostJob

@martel This is just a simple test to deal with tDie and PostJob

 

In fact what i really need is that tPostjob part (whatever it contains) execute in anycase

 

But stopping job execution in case of tDie (DB connection error, missing file...)

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog

Downloads and Trials

Test drive Talend's enterprise products.

Downloads