You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by mbhaya <mo...@gmail.com> on 2013/05/11 21:46:07 UTC

Not able to get Http Response message/code in case of wrong URI

Hi

I am new to camel and was exploring onException clause. I am using the
following way to handle exception.
<onException>
<exception>java.lang.Exception</exception>
<handled><constant>true</constant></handled>
<process ref="testProcessor"/>
</onException>

Following is the route that I have defined:
<from uri="restlet:http://localshost:9090/user">
<enrich uri="http4://www.api/" strategyRef="testStrategy"/>

now in order to test exception i have specified a wrong URI above in the
enrich clause. when i run this exception is generated but I am not able to
get the http response message or response code in the processor that I have
specified in the exception clause.

Kindly suggest.




--
View this message in context: http://camel.465427.n5.nabble.com/Not-able-to-get-Http-Response-message-code-in-case-of-wrong-URI-tp5732345.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Not able to get Http Response message/code in case of wrong URI

Posted by mbhaya <mo...@gmail.com>.
In testProcessor I just have one method void process(Exchange e)...
I want the http status code or response message..I tried to get it from
Exchange.HTTP_STATUS_CODE but it gives a null value...



--
View this message in context: http://camel.465427.n5.nabble.com/Not-able-to-get-Http-Response-message-code-in-case-of-wrong-URI-tp5732345p5732382.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Not able to get Http Response message/code in case of wrong URI

Posted by Willem jiang <wi...@gmail.com>.
What are you doing in the testProcessor?


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Sunday, May 12, 2013 at 3:46 AM, mbhaya wrote:

> Hi
>  
> I am new to camel and was exploring onException clause. I am using the
> following way to handle exception.
> <onException>
> <exception>java.lang.Exception</exception>
> <handled><constant>true</constant></handled>
> <process ref="testProcessor"/>
> </onException>
>  
> Following is the route that I have defined:
> <from uri="restlet:http://localshost:9090/user">
> <enrich uri="http4://www.api (http://www.api)/" strategyRef="testStrategy"/>
>  
> now in order to test exception i have specified a wrong URI above in the
> enrich clause. when i run this exception is generated but I am not able to
> get the http response message or response code in the processor that I have
> specified in the exception clause.
>  
> Kindly suggest.
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Not-able-to-get-Http-Response-message-code-in-case-of-wrong-URI-tp5732345.html
> Sent from the Camel Development mailing list archive at Nabble.com (http://Nabble.com).




Re: Not able to get Http Response message/code in case of wrong URI

Posted by mbhaya <mo...@gmail.com>.
Thanks..!!



--
View this message in context: http://camel.465427.n5.nabble.com/Not-able-to-get-Http-Response-message-code-in-case-of-wrong-URI-tp5732345p5732449.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Not able to get Http Response message/code in case of wrong URI

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Next time you should use the user mailing list for your questions about Camel
http://camel.apache.org/mailing-lists.html

The status code is on the
org.apache.camel.component.http.HttpOperationFailedException

You can get it like this:

HttpOperationFailedException e =
exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
HttpOperationFailedException.class);

int code = e.getStatusCode();




On Mon, May 13, 2013 at 7:46 AM, mbhaya <mo...@gmail.com> wrote:
> I have seen the link..but wanted to ask is there any way in Camel to access
> Http status code in case I am getting an exception..
> Pleas help..!!
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Not-able-to-get-Http-Response-message-code-in-case-of-wrong-URI-tp5732345p5732386.html
> Sent from the Camel Development mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Not able to get Http Response message/code in case of wrong URI

Posted by mbhaya <mo...@gmail.com>.
I have seen the link..but wanted to ask is there any way in Camel to access
Http status code in case I am getting an exception..
Pleas help..!!



--
View this message in context: http://camel.465427.n5.nabble.com/Not-able-to-get-Http-Response-message-code-in-case-of-wrong-URI-tp5732345p5732386.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Not able to get Http Response message/code in case of wrong URI

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

See this link
http://camel.apache.org/why-is-the-exception-null-when-i-use-onexception.html

On Sat, May 11, 2013 at 9:46 PM, mbhaya <mo...@gmail.com> wrote:
> Hi
>
> I am new to camel and was exploring onException clause. I am using the
> following way to handle exception.
> <onException>
> <exception>java.lang.Exception</exception>
> <handled><constant>true</constant></handled>
> <process ref="testProcessor"/>
> </onException>
>
> Following is the route that I have defined:
> <from uri="restlet:http://localshost:9090/user">
> <enrich uri="http4://www.api/" strategyRef="testStrategy"/>
>
> now in order to test exception i have specified a wrong URI above in the
> enrich clause. when i run this exception is generated but I am not able to
> get the http response message or response code in the processor that I have
> specified in the exception clause.
>
> Kindly suggest.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Not-able-to-get-Http-Response-message-code-in-case-of-wrong-URI-tp5732345.html
> Sent from the Camel Development mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen