We use this

<onException useOriginalMessage="true">
                                <exception>java.lang.Exception</exception>
                                <onWhen>
                                        <simple>${exception.message} contains 
'404' or ${exception.message} contains '405' or ${exception.message} contains 
'500' or ${exception.message} contains '401' or ${exception.message} contains 
'java.net.SocketTimeoutException' or ${exception.message} contains 'Connection 
timed out' or ${exception.message} contains 'SSL' or ${exception.message} 
contains '400' or ${exception.message} contains 'Connection reset' or 
${exception.message} contains 'handshake' or ${exception.message} contains 
'socket' or ${exception.message} contains 'Socket'</simple>
                                </onWhen>

But we throw exception on failure.

The cases where we don't throw, we have only http 200 status returned.

Vanshul

-----Original Message-----
From: Alex Soto [mailto:[email protected]] 
Sent: Friday, April 08, 2016 9:39 AM
To: [email protected]
Subject: Accessing the HTTP Response Code with netty4 

Hello:

I am using Camel 2.16.2  and I have a route with a Netty4 HTTP producer calling 
a remote HTTP server.  I am passing the option throwExceptionOnFailure=false.  
Upon return,  I need to check the HTTP response code like this:

<filter>
        <simple>${header.CamelHttpResponseCode} == 403</simple>
        
        . . . 
</filter>


The problem is that the CamelHttpResponseCode is always null. I can see it the 
trace logs:

Headers:{CamelHttpResponseCode=null, Connection=keep-alive, 
CamelHttpResponseText=Not Modified, Content-Length=0}


How can I check the HTTP response code?


Best regards,
Alex soto





Reply via email to