Send Failure Email Notification Error

One Star

Send Failure Email Notification Error

Hi Friends,
I am new to Talend. Trying to use email component to send email on job successes or failure.
I am able to send on success, but even on failure it's sending the success email. my job flow is as follows,
tFTPConnection_1 --(ONComponentOK)-->tFTPPut_1----(ONComponentOK)-->tSendMail_1
|
|
(OnComponentError)
|
\/
tSendMail_2
In tFTPPUT_1 , I have checked the option "Die on Error". (Even I unchecked this and tested, but no luck).
Please help me to resolve this problem
Thanks.
One Star

Re: Send Failure Email Notification Error

To handle sending e-mails on success or error, I have usually done something like this:
tMyComponent_1 --(OnComponentOK)--> tFileList_1 --(If [((Integer)globalMap.get("tFileList_1_NB_FILE"))==0) -->tSendMail_1 (success)
Then another if that points to tSendMail_2 with criteria: ((Integer)globalMap.get("tFileList_1_NB_FILE")) > 0
The tFileList component looks at an "error" directory, and if any kind of error occurs, a file is created in that directory by using tLogCatcher -> tMap -> tFileOutputDelimited in my Talend jobs. If no error occurs, directory is empty, success email sends. If there is a file, an error occurred, attach the error file to the email and send.
Hope that helps
One Star

Re: Send Failure Email Notification Error

Let me try this.
And one more Question:
How I can include the current date in the content of the email and in subject line?
Thanks.
Seventeen Stars

Re: Send Failure Email Notification Error

You can get the current date as String this way:
TalendDate.formatDate("yyyy-MM-dd", TalendDate.getCurrentDate())
Example for subject line: "The job runs at " + TalendDate.formatDate("yyyy-MM-dd", TalendDate.getCurrentDate()) + " fails"
One Star

Re: Send Failure Email Notification Error

Hi, can you please let me know how I implement this?
The tFileList component looks at an "error" directory, and if any kind of error occurs, a file is created in that directory by using tLogCatcher -> tMap -> tFileOutputDelimited in my Talend jobs. If no error occurs, directory is empty, success email sends. If there is a file, an error occurred, attach the error file to the email and send.
where i can find the "Error" directory in tFileList component?
One Star

Re: Send Failure Email Notification Error

The error directory that I refer to is actually just any directory, it just has to be the directory where you place any error files when they occur.
You could create a context variable called errorDir and have that be any directory you like.
If you use tLogCatcher -> tMap -> tfileOutputDelimited, you can set the File Name of the tFileOutputDelimited to context.errorDir + "/errors.csv", and check the append box if you'd like.
Now, whenever an error happens, it'll be written to /errors.csv
For the tFileList component, you can set the directory to context.errorDir, and add a FileMask of "*.csv" if you'd like.
For the tSendMail when an error is found, you can set the attachment File to be context.errorDir + "/errors.csv", and it'll add the file to the e-mail that is sent on error.
One Star

Re: Send Failure Email Notification Error

Hi,
This scenario is not working for me.
I am receiving this error and also it's doing ftp and sending success email. Even If files are not exists, in that case also it's sending success email.

connecting to socket on port 3774
connected
Exception in component tFTPPut_1
java.lang.NullPointerException
at dev_jbjs.copy_of_hw_ftp_0_1.Copy_of_HW_FTP.tFTPPut_1Process(Copy_of_HW_FTP.java:911)
at dev_jbjs.copy_of_hw_ftp_0_1.Copy_of_HW_FTP.tFTPConnection_1Process(Copy_of_HW_FTP.java:624)
at dev_jbjs.copy_of_hw_ftp_0_1.Copy_of_HW_FTP.runJobInTOS(Copy_of_HW_FTP.java:3269)
at dev_jbjs.copy_of_hw_ftp_0_1.Copy_of_HW_FTP.main(Copy_of_HW_FTP.java:3059)
disconnected