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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

[resolved] Email notification in case of job failure

Hi,
I have a job that takes all data from oracle table and insert it in to ms sql table.
Ex: tOracleInput==>tmap==>tmsSqlOutput
Now, in case the job fails - due to any reason (say database went down or incorrect connection settings or any mismatch etc), I want to capture the error log in a email. I want to notify by sending email that the job has been failed with the error code attached in email body.
I tried 2 approaches using tSendMail component as given below:
Approach1 : tOracleInput==>tmap==>tmsSqlOutput==>onComponentError==>tSendMail
Approach2: tOracleInput==>tmap==>tmsSqlOutput==>onComponentError==>tDie
and tLogCatcher==>tSendMail
But I was not able to get the expected result with these 2 approaches.
Please help me out here!! Appreciate the responses with solutions.

Thanks
Xan
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi
What's the problem? You don't receive the email or the error message is null in the email body? Any case, the job design looks like:
tOracle--main--tMssql

tLogCatcher--main--tJavaRow
|
onsubjobok
|
tSendmail
uncheck the option 'die on error' on all the component, so that the job will throw the exception once fails and die.
on tJavaRow:
globalMap.put("errorCode", input_row.message);
on the message body of tsendmail:
"the error message is: "+(String)globalMap.get("errorCode")
uncheck the option 'die on error' on all the components.

Best regards
Shong

View solution in original post

13 Replies
Anonymous
Not applicable

The catch java exception and catch error check boxes on tLogCatcher are checked!! Still the issue!
Anonymous
Not applicable

Hi
What's the problem? You don't receive the email or the error message is null in the email body? Any case, the job design looks like:
tOracle--main--tMssql

tLogCatcher--main--tJavaRow
|
onsubjobok
|
tSendmail
uncheck the option 'die on error' on all the component, so that the job will throw the exception once fails and die.
on tJavaRow:
globalMap.put("errorCode", input_row.message);
on the message body of tsendmail:
"the error message is: "+(String)globalMap.get("errorCode")
uncheck the option 'die on error' on all the components.

Best regards
Shong
Anonymous
Not applicable

Thanks for the response Shong!
It does work now. I forgot to uncheck the die on error option. Thanks again! Really appreciate it.
Anonymous
Not applicable

Thanks for the response Shong!
It does work now. I forgot to uncheck the die on error option. Thanks again! Really appreciate it.

Good news, thanks for your feedback!
Best regards
Shong
Anonymous
Not applicable

Hi Shong,
I was working on the other approach for this same functionality. When there is any failure to Talend Job, I have written a java class which sends email. This routine I have saved in the Routines section in talend. Now, how to call this routine when the job fails?
Suppose I have the routine named "sendEmail" and I have written the usual java mail code to send email(It has a main() method and inside main (), the send() method is called. This send() method sends the email actually). Now, in order to call this routine when our talend job fails, will it be called as:
tlogCatcher--onSubjobOk-->tJava
On tJava: just sendMail.this ? It did not work this way, so was wondering if you can give your inputs!
Anonymous
Not applicable

Hi
There should not be a main() method in the routine, please take a look at the system routines. To call a routine method, the format is routineName.methodName, for example:
tlogCatcher--onSubjobOk-->tJava
on tJava:sendEmail.send()
Best regards
Shong
Anonymous
Not applicable

Got it!! thanks much man!
Anonymous
Not applicable

Hello,
I was trying to implement several approaches of sending email. I tried sending email if the job fails to run and sending attachment with the email. Now I was trying with sending a plain email if the job fails and below was the code I wrote for it -
tOracleInput-->tMap-->tMySQLOutput
tLogCatcher--row1-->tFileOutputXML
|
onSubjobOk
|
tSendMail1
Now I have set all the properties. when I run the job, it triggers email 2 times. I verified the parameters and there is really nothing specific mentioned in this simple job which will trigger email twice.
Can anyone please help me here, why am I getting 2 emails instead of one simple email - as per this flow. . ?
Thanks
Xan
Anonymous
Not applicable

Hi Xan
I don't understand why it sends two emaisl either. Even, I don't believe the two emails are sent from the same component in this job. Do you have other subjobs in this job?
Best regards
Shong