camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Getting http status code from cxfrs in onException handler
Date Mon, 02 Dec 2013 07:38:19 GMT
Hi,

I just checked the code of CxfRsProducer, if you set the throwExceptionOnFailure to be true,
you can only get the Http status code from the exception.
If you set the throwExceptionOnFailure option to be false, you can find the Http status code
from the out message header with the key of “CamelHttpResponseCode”.

-- 
Willem Jiang
Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
          http://jnn.iteye.com (Chinese)
Twitter: willemjiang 
Weibo: 姜宁willem


On November 29, 2013 at 3:44:09 PM, Preben.Asmussen (pras@dr.dk) wrote:
>
>Hi
>
>I have a onException block where i want to handle
>org.apache.camel.component.cxf.CxfOperationException
>but only when the status is 404. other status codes should fail and
>rollback.
>
>The route is ->
>
>>uri="hubTopic:topic:CMS_CONTENT_HUB?clientId=NEWS&durableSubscriptionName=NEWS"
>/>
>
>
>org.apache.camel.component.cxf.CxfOperationException
>
>
>
>true
>
>
>
>>uri="cxfrs:bean:allnews?synchronous=true&throwExceptionOnFailure=true"/>
>
>
>the HttpExceptionInterpreter is kind of simple ->
>public static boolean is404(@ExchangeException CxfOperationException
>exception) {
>return exception.getStatusCode() == 404;
>}
>
>I would guess that I could avoid the bean, and that the http status code
>would be set on the exchange header (in or out) so that i could use the
>simple language to do something like out.header.xxxx == 404 in the
>onWhen.
>
>Is that possible ?
>
>There is no http status code on the in.header btw.
>
>I'm using Camel version 2.11.1
>
>Best,
>Preben
>
>
>
>
>--
>View this message in context: http://camel.465427.n5.nabble.com/Getting-http-status-code-from-cxfrs-in-onException-handler-tp5744066.html
>Sent from the Camel - Users mailing list archive at Nabble.com.
>


Mime
View raw message