Six Stars

How to get last Successful end date of job in variable

Hi,

I want to retrieve the end date of my job if the execution is completed successfully in a variable.

I tried to do that but it doesn't work

b.PNGa.PNG

Best regards !

1 ACCEPTED SOLUTION

Accepted Solutions
Ten Stars

Re: How to get last Successful end date of job in variable

all there

 

vapukov wrote:

You not explain Your error, but at least:

message not always "success", it could be null, and it will return NULL pointer error for equals

 

 

so You need at least add compare with null

!message==null && message.equals("success")

 

Check for null always - first

-----------
14 REPLIES
Ten Stars

Re: How to get last Successful end date of job in variable

You can use tPostJob and

TalendDate.getDate("yyyy-MM-dd hh:mm:ss") 

 or You can use same in tJavaRow

 

Screen Shot 2017-05-29 at 11.48.49 PM.png

 

Starting job endDT at 23:48 29/05/2017.

[statistics] connecting to socket on port 3490
[statistics] connected
2017-05-29 23:48:42
[statistics] disconnected
Job endDT ended at 23:48 29/05/2017. [exit code=0]

 

-----------
Six Stars

Re: How to get last Successful end date of job in variable

Yes it allows to get the execution date but I need a condition to see if the job is successfully completed or not. If successfully I record the end date of execution in a variable.

Ten Stars

Re: How to get last Successful end date of job in variable

You not explain Your error, but at least:

message not always "success", it could be null, and it will return NULL pointer error for equals

Screen Shot 2017-05-30 at 12.54.32 AM.png

 

so You need at least add compare with null

meesage!=null && message.equals("success")

 

second - stat catcher - lat component (last from last) if You try to check Job finish, so - where You plan use variable if nothing run after?

 

-----------
Six Stars

Re: How to get last Successful end date of job in variable

Here is my job : 

job.PNG

Last_Date_Out : contains last execution date than i get this date to filter my files tike this :

job1.PNG

This job works but I need a test to check that the last execution date is made following a success. Because my job is going to be run every night automatically so I need to resume the error if there ever was an interruption.

Ten Stars

Re: How to get last Successful end date of job in variable

I think You need connect tStatCatcher just to tlogrow (or direct to csv)

and this is give You ideas - what to check

 

You must handle nulls exactly

 

see for picture above

 

BUT!!!

 

in Your case - think it not help!

 

because - stat catcher catch begin and end ... and what if error (not success) after 30 minutes of Your long Job?

what You will catch? time will be wrong

-----------
Six Stars

Re: How to get last Successful end date of job in variable

Yes exactly i agree with you, for this reason I used tjavarow at the beginning to get the end date of execution if the message = success and therefore if not we start the job manually the next day after having had an email or a notification of the error...

Ten Stars

Re: How to get last Successful end date of job in variable

so, add null check before equals - and it must work without error

think - not proper, but at least without errors :-)

-----------
Six Stars

Re: How to get last Successful end date of job in variable

T get this error : 

e1.PNGe2.PNG

Ten Stars

Re: How to get last Successful end date of job in variable

do You have output_row? add tLogRow after tJavaRow

 

 

-----------
Six Stars

Re: How to get last Successful end date of job in variable

job.PNGjob1.PNG

Ten Stars

Re: How to get last Successful end date of job in variable

read above - CHECK NULLS! :-)

-----------
Six Stars

Re: How to get last Successful end date of job in variable

Sorry for the question but I thought I should add .equal("null")in tjavarow as the figure above if it is not so where i check ?

Ten Stars

Re: How to get last Successful end date of job in variable

all there

 

vapukov wrote:

You not explain Your error, but at least:

message not always "success", it could be null, and it will return NULL pointer error for equals

 

 

so You need at least add compare with null

!message==null && message.equals("success")

 

Check for null always - first

-----------
Six Stars

Re: How to get last Successful end date of job in variable

Thank you for your explanations Smiley Happy