Hi Yogesh,
Your case is different, as you are not using the camel transport for
CXF, so you can't get any camel exchange from the message context.
As you are using the one way operation camel may not get the exception,
I will need to write a simple test case to dig the code for it.
On 2/17/12 3:57 AM, ychawla wrote:
Hi Sven,
I think I am seeing the same behavior that you are. I have a one-way
service in CXF. For test purposes, I shut down the service and have the
client invoke the service through a camel route:
<camel:route errorHandlerRef="myDeadLetterErrorHandler">
<camel:from uri="inputDir"/>
<camel:setHeader
headerName="operationName"><constant>opName</constant></camel:setHeader>
<camel:setHeader
headerName="operationNamespace"><constant>opNamespace</constant></camel:setHeader>
<camel:to uri="cxf:bean:myService?dataFormat=PAYLOAD"/>
</camel:route>
I see an error in my logs which I except, but the dead letter error handler
never gets invoked:
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)[:1.6.0_29]
at
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)[:1.6.0_29]
at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)[:1.6.0_29]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)[:1.6.0_29]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)[:1.6.0_29]
I assume this is because Camel is not getting the exception thrown by CXF. I
have tried to add an interceptor similar to what you suggest. However, the
interceptor never gets invoked (that is why you see it on the in,out,
infault, and outfault):
<cxf:cxfEndpoint
id="myService"
address="http://localhost:8080/service"
wsdlURL="myService.wsdl"
serviceName="test:ServiceService"
endpointName="test:Service"
xmlns:test="http://www.test.com"
>
<cxf:inInterceptors>
<ref bean="camelExceptionInterceptor"/>
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="camelExceptionInterceptor"/>
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<ref bean="camelExceptionInterceptor"/>
</cxf:outFaultInterceptors>
</cxf:cxfEndpoint>
and then I have the bean where I declare it:
<bean id="camelExceptionInterceptor"
class="org.test.cxf.interceptor.CamelExceptionInterceptor"/>
and then the actual interceptor:
import org.apache.camel.Exchange;
import org.apache.camel.component.cxf.CxfConstants;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
public class CamelExceptionInterceptor extends
AbstractPhaseInterceptor<Message> {
public CamelExceptionInterceptor() {
super(Phase.RECEIVE);
}
@Override
public void handleFault(Message message)
{
Exception exception = message.getContent(Exception.class);
Exchange exchange = (Exchange)
message.get(CxfConstants.CAMEL_EXCHANGE);
exchange.setException(exception);
}
@Override
public void handleMessage(Message message) throws Fault {
// TODO Auto-generated method stub
String hello = "helloWorld";
}
}
Any idea what I am doing wrong? My interceptor never gets invoked. I would
like to grab the exception from CXF and make the camel exchange aware of it.
If there is an easier way to set up my error handler, that would be great as
well.
Thanks!
Yogesh
--
View this message in context:
http://cxf.547215.n5.nabble.com/CXF-Camel-JMS-Endpoint-exception-handling-tp4471174p5490565.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang