One Star

cCXF Fault Handling

Hello,
I would like to add some kind of Fault Handling after a cCXF Service Call. For example if the Service is not available I would like to reattempt the Service-Call after 10 seconds.
I looked at the cErrorHandler Component, but when I get the org.apache.cxf.interceptor.Fault message nothing happends.
The same with the cTry - catch component. Catching the org.apache.cxf.interceptor.Fault does not work. The same with the cException component.
So what could I do?
Thanks in advance!

11 REPLIES
Employee

Re: cCXF Fault Handling

You need to turn on handleFault. Endpoints in Camel throw Faults which are by default not handled by the Exception mechanism. I think the method can be invoked on either the route or the camel context scope. It is some like
context.setHandleFault(true)
Not sure off the top of my head if there is a separate handleFault component in the Camel Studio palette. If not, you can set it in the cConfig.
One Star

Re: cCXF Fault Handling

Hi,
in Talend 5.1.1 you can use a cErrorHandler component where you can set error handling strategies (such as number of redeliveries, delay, DLQ, etc).
Gabriel
One Star

Re: cCXF Fault Handling

Thanks for your answers, but I could not get it to work.
I have a cContext var with "camelContext.sethandleFault(true)",
I have a cErrorHandler with retries and so on,
I have a cOnException component with java.lang.Exception, RuntimeException and org.apache.cxf.interceptor.Fault
I am calling the cCXF from a try component and catch it to a cLog with "Exception.class"
Ich tested many combinations from aboce and all together, I am always getting:
 PhaseInterceptorChain          WARN  Interceptor for {http://auftragsverwaltung.masterarbeit.isst.fraunhofer.de/}NotifyShipmentUnitServerService#{http://www.openapplications.org/oagis/9/ws}NotifyShipmentUnit 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:262)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:532)

I do not have the chance to do any stuff when this fault arises. The route is still ending.
Do you have any other ideas?
One Star

Re: cCXF Fault Handling

Hello again,
I did some further tests. Generally the cErrorHandler and tryCatch components works in minimal examples. I have configured the cErrorHandler as a LoggingHandler.
The config is:
cCXF1 -> cProcessor1 -> cCXF2
For example when I send wrong Message Payload to the Endpoint cCXF2 the Logger catches the Fault. Also the try catch would work.
If I send correct Payload to cCXF2 which I set in the cProcessor, everything is fine when the Servcie from cCXF2 is on. But when I after such a successful test turn off the Server of cCXF2 and the Service cannot be called, I get the the Fault I posted above and the Logger or a TryCatch construct doesn't do anything.
Test Scenario:
1: Starting Server (for cCXF2)
2: Starting Route (Open Studio, deployed in Karaf has same effect)
3. Call cCXF1 Service, Set new Message Payload, call cCXF2 and the Server --> Successful
4. Switch off Server (where cCXF2 is linked to)
5. Call cCXF1 the same way
6. Getting the uncatched Fault
Code of cProcessor1:
exchange.getOut().setBody("normalizedString1967-08-13normalizedStringString3");

cCXF1 has absolut Path on Filesystem to a WSDL, Dataformat: PAYLOAD
cCXF2 has an URI to a WSDL, Dataormat PAYLOAD
cErrorHandler: LoggingHandler
One Star

Re: cCXF Fault Handling

I did another test where I only redirect the original payload of the service without changing the body/head:
cCXF1 --> cCXF2
When I kill the Server off cCXF2 and call the cCXF1 at this scenario the tryCatch and ErrorHandler are working fine.
So there is a problem with error handling when the body is manipulated by a processor...
Employee

Re: cCXF Fault Handling

Hi Reimy
Thanks for the update. I will see if I can replicate it on my end. Could you post a JIRA ticket on the Talend ESB at http://jira.talendforge.org/browse/TESB ? I will post any of my comments and samples reproducing the error on that JIRA ticket for our Support team as well. Thanks.
Ed
One Star

Re: cCXF Fault Handling

Hey again,
I have created the ticket: http://jira.talendforge.org/browse/TESB-6265
Thanks in advance!
Employee

Re: cCXF Fault Handling

fault is not an exception. if you want to use the cOnException to catch the fault, you have to transfer the fault to an exception by enable the handleFault=true, this can be done by using "context.setHandleFault(true)" or add ".handleFault()" after "from()", for example, " from(...).handleFault().to(...)".
One Star

Re: cCXF Fault Handling

Thanks for your answers, but I could not get it to work.
I have a cContext var with "camelContext.sethandleFault(true)",
I have a cErrorHandler with retries and so on,
I have a cOnException component with java.lang.Exception, RuntimeException and org.apache.cxf.interceptor.Fault
I am calling the cCXF from a try component and catch it to a cLog with "Exception.class"

As I mentionend on Post 4 this didn't work for me. It works in an minimal example but not in my route.
Employee

Re: cCXF Fault Handling

There are two ways to enable handleFault() in Talend Studio. It can have context scope (all routes) if you set it in cConfig. Add the code camelContext.setHandleFault() to the cConfig component. If you wish to add it with route scope add it with a javaDSL component immediately after the start of the route. The resulting route should look something like:
from("myuri:xxx").handleFault().xxx
One Star

Re: cCXF Fault Handling

wrong place