Capture all exceptions in ESB route

Six Stars

Capture all exceptions in ESB route

Hi All, 

 

We are able to send general email using cMail component.But how to send emails for all exceptions in ESB route? I have seen the cOnexception. But not sure what all exceptions(like java.lang.Exception) needs to be added in advanced setting so that all errors can be captured so that email notification can be sent. 


Accepted Solutions
Community Manager

Re: Capture all exceptions in ESB route

I've also noticed that you errors are fundamental flaws with your Route. Your route cannot run with those errors. Can you create a route with an intermittent divide by 0 error (or similar)? Something like a cTimer--->cProcessor (with the divide by 0 error) and your cOnException process.

 

I don't believe the the cOnException component will work very well with fundamental route issues. I believe it will work better for intermittent data errors (in Beans, etc).


All Replies
Community Manager

Re: Capture all exceptions in ESB route

java.lang.Exception should catch all Exceptions for you. If you want to catch absolutely anything that could be thrown by the Route, you could try using java.lang.Throwable. I've not actually tried this myself, but it should work.

Six Stars

Re: Capture all exceptions in ESB route

No luck. I tried keeping java.lang.Throwable and tried keeping other exceptions in the pic in advanced setting. Here are the errors I generated which are not captured. Not sure if my approach is correct.

Failed to create Producer for endpoint: 

org.apache.kafka.common.KafkaException: Failed to construct kafka producer

java.io.FileNotFoundException etc

2018-10-28 15_00_14-Amazon WorkSpaces.png

2018-10-28 14_55_50-Amazon WorkSpaces.png

Community Manager

Re: Capture all exceptions in ESB route

You need to "Handle the Exceptions" to enable this I believe. Unfortunately I cannot test this on my machine at the moment as I don't have ESB on here. But on looking at your screenshot, you have "None" selected for the "Exception Behaviour"

Six Stars

Re: Capture all exceptions in ESB route

I tried by keeping the handle exception as well.
Community Manager

Re: Capture all exceptions in ESB route

What happens when you do that? I am suspicious as to whether the cMail is causing some confusion here. Maybe temporarily replace it with a cProcessor and a simple System.out

Community Manager

Re: Capture all exceptions in ESB route

I've also noticed that you errors are fundamental flaws with your Route. Your route cannot run with those errors. Can you create a route with an intermittent divide by 0 error (or similar)? Something like a cTimer--->cProcessor (with the divide by 0 error) and your cOnException process.

 

I don't believe the the cOnException component will work very well with fundamental route issues. I believe it will work better for intermittent data errors (in Beans, etc).

Six Stars

Re: Capture all exceptions in ESB route

I assumed cOnexception works like tlogcatcher in DI where it captures some of the errors like Table not found. The solution u suggested to keep 4/0 triggered the cOnexception. But I have one observation, I have the below 3 statements in cprocessor. In this case, 2nd statement threw exception and  the 3rd statement is not executed. As soon as there is exception, cOnexception is getting triggered and remaining statements in cprocessor are not getting executed. I observed the sme case with ignore exceptions, handle exceptions , none in conexception component. Is there a way to ignore the exception , keep the route running for next messages and to get email notification for exception so that prod support team can look into the exceptions.

2018-10-28 22_37_43-Talend Real-time Big Data Platform (6.4.1.20170623_1246) _ esb_demo_project (Con.png

2018-10-28 22_36_56-Talend Real-time Big Data Platform (6.4.1.20170623_1246) _ esb_demo_project (Con.png

Community Manager

Re: Capture all exceptions in ESB route

I think you have to treat exceptions like you would in a Java try/catch block. As soon as you get an exception within the same try/catch (a single component would behave like this), the catch is initiated and the flow is changed.

Six Stars

Re: Capture all exceptions in ESB route

So in that case. As soon as we get a error, exception will be activated and we get email regarding the exception. Next messages in the queue will not processed. Is there any way to ignore the exception and keep updates flowing, send email in case as soon as the exception is identified ?

Community Manager

Re: Capture all exceptions in ESB route

A problem which means a route is broken (missing endpoint within the same route, etc) will prevent the route from functioning. You should not allow issues like that to get beyond testing. Issues like the divide by 0 error I mentioned above that can be caused by your data, should not crash the route and you should be able to achieve what you have mentioned in your last post.

 

One thing to keep in mind with routes, you should test them in the Karaf (ESB runtime) and not just the Studio. You will likely see a slightly different behaviour with your errors and how they are handled.

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read