One Star

tESBConsumer how to catch and email error / exception

Hi,
I have a job with a tESBConsumer that calls a Soap service. However when the service is down for example I want to have an email with the error emailed to me.
I tried the Fault output or OnComponentError, but I am not able to catch the error and reroute it to be sent as an email.
How to do his?
11 REPLIES
Community Manager

Re: tESBConsumer how to catch and email error / exception

Hi
Do you have output in the Fault output flow? or the job throws exception and die? Can you show me the error message printed on the console?
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tESBConsumer how to catch and email error / exception

And what version of Talend or you using?
One Star

Re: tESBConsumer how to catch and email error / exception

I am using TOS 5.02 (latest stable release). To simulate that the Soap service I am connecting to is down, I am using a non existing URL to connect the service to.
btw I tried it with the option 'Die on error' in the component set on or off, but it makes no difference.
When I run the job I get the following error:
3-mei-2012 11:35:26 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://www.talend.org/service/}orderStatusService#{http://cxf.apache.org/jaxws/dispatch}Invoke has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:533)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
at org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:354)
at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:381)
at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:241)
at org.talend.ws.helper.ServiceInvokerHelper.invoke(ServiceInvokerHelper.java:275)
at org.talend.ws.helper.ServiceInvokerHelper.invoke(ServiceInvokerHelper.java:167)
at bus001test.checksoapalive_0_1.checkSoapAlive.tFixedFlowInput_1Process(checkSoapAlive.java:1941)
at bus001test.checksoapalive_0_1.checkSoapAlive.runJobInTOS(checkSoapAlive.java:5038)
at bus001test.checksoapalive_0_1.checkSoapAlive.main(checkSoapAlive.java:4885)
Caused by: java.net.UnknownHostException: UnknownHostException invoking http://soapdummy: soapdummy
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1431)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1416)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:649)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
... 13 more
Caused by: java.net.UnknownHostException: soapdummy
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at sun.net.NetworkClient.doConnect(NetworkClient.java:158)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1014)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1368)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1310)
at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42)
at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1388)
... 16 more
Could not send Message.
disconnected
Job checkSoapAlive ended at 11:35 03/05/2012.
Community Manager

Re: tESBConsumer how to catch and email error / exception

Hi
Add a tLogCatcher component in the job to capture the error and store it into a global variable which you will send it on a tSendMail component. For example:
...tESBConsumer...
tLogCapture--main--tJavaRow
|
onsubjobok
|
tSendMail
on tJavaRow, putthe error message to a global variable, for example:
globalMap.put("message", input_row.message);
on tSendMail, set the message field as something like this:
"The job runs failure, the error message is: "+(String)globalMap.get("message")
In this case, a email is sent only when the job works failure.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tESBConsumer how to catch and email error / exception

Hi,
I tried your example with the tLogCatcher and then in the tJavaRow I used System.out.println( "ERROR:" + row4.message );
But this is never printed, not in the console or in the logfile?. It looks like the exceptions are not logged?
In my projects settings->Job Settings my stats & logs are directed to a database, but in this job I disabled this.

I added the settings of my job->Stats & logs and my tLogCatcher settings.

Is there a setting here I need to change?
Community Manager

Re: tESBConsumer how to catch and email error / exception

Hi
On tJavaRow component, the correct expression should be:
System.out.println( "ERROR:" + input_row.message );
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tESBConsumer how to catch and email error / exception

Hi,
I tried input_row.message but same results, the tESBConsumer exception is not catched.
To test if other exceptions are catched I added a tJavaRow in my flow containing an exception:
String a = null;
a.indexOf(1);

And when I now run the job then this exception is catched:
ERROR:java.lang.NullPointerException:null
It looks like this is a bug in tESBConsumer that exceptions are not catched at all?
Community Manager

Re: tESBConsumer how to catch and email error / exception

Hi
Have you checked the option 'die on error' on tESBConsumer? In my job, tLogCatcher component catchs the excepttion thrown by tESBConsumer.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tESBConsumer how to catch and email error / exception

Hi,
Yes!, enabling the 'Die on error' helps, now I am getting more info:
javax.xml.ws.WebServiceException:Could not send Message.,code=1
However the complete stacktrace itself is not printed, is it posisble to get the stacktrace as well?
Community Manager

Re: tESBConsumer how to catch and email error / exception

Hi
Can you please upload some screenshots of job or export the job and send it to me via email for further investigation?
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tESBConsumer how to catch and email error / exception

Hi Shong,
I emailed the job to you, thanks for the help!