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: Camel HTTP producer successful on 404?
Date Sun, 28 Sep 2008 04:12:04 GMT
FYI

I created a JIRA[1] and did a quick fix for it.
[1] https://issues.apache.org/activemq/browse/CAMEL-943

Willem

Willem Jiang wrote:
> We can deal with 3xx, 4xx, 5xx with this kind of 
> HttpOperationFailedException.
> Since HttpClient already has the transport exceptions and protocol 
> exceptions, we are doing nothing about these exceptions.They will be 
> thrown directly if the HttpClient throws them.
>
> Willem
> Claus Ibsen wrote:
>> Hi
>>
>> Yeah for 3xx we should get the location that is returned, if any 
>> provided:
>>
>> http://hc.apache.org/httpclient-3.x/redirects.html
>> Header locationHeader = method.getResponseHeader("location");
>>
>> So the end-user can get this new location and retry if he wants to.
>>
>> Yeah maybe we need a special exception where we can store this 
>> location if there is one.
>>
>> Would be fine with a HttpOperationFailedException where we can have 
>> such details stored.
>> - error code
>> - status line
>> - location
>>
>> And it could have a isRedirectError() + hasRedirectLocation () or 
>> whatever so you can do
>>
>> Catch (HttpOperationFailedException e) {
>> If (e.isRedirectError() && e.hasRedirectLocation()) {
>>    // retry with the new location
>>
>> }
>>
>>
>>
>> Med venlig hilsen
>>  
>> Claus Ibsen
>> ......................................
>> Silverbullet
>> Skovsgårdsvænget 21
>> 8362 Hørning
>> Tlf. +45 2962 7576
>> Web: www.silverbullet.dk
>>
>> -----Original Message-----
>> From: Willem Jiang [mailto:willem.jiang@gmail.com] Sent: 27. 
>> september 2008 10:07
>> To: camel-user@activemq.apache.org
>> Subject: Re: Camel HTTP producer successful on 404?
>>
>> I just checked doc of HttpClient[1] , it will not handler redirection 
>> automatically.
>> "Currently HttpClient is unable to automatically handle redirects of 
>> entity enclosing methods such as POST and PUT."
>> Here is a question, if we just throw the exception when we get the 
>> 3xx, how can we extract the location of redirect response from the 
>> exception ?
>> Or we can create a ProtocalExcpection to store the response code and 
>> detail response message.
>>
>> [1] http://hc.apache.org/httpclient-3.x/redirects.html
>>
>> Willem
>> Claus Ibsen wrote:
>>  
>>> Hi
>>>
>>> About: Some of the 3xx errors. Does the http client lib support 
>>> redirection (follow redirection flag or something?). Maybe if there 
>>> was such a flag we should allow this to be configured as well. So 
>>> camel would follow the redirection instruction returned.
>>>
>>>
>>> And it should be documented in the wiki, what we do for the 
>>> different http return codes!
>>>
>>> I don't think we should set any reponse to the FAULT message as we 
>>> are about to @deprecate / alter this for the future. And FAULT is 
>>> seldom used in Camel.
>>>
>>> Otherwise +1
>>>
>>> Med venlig hilsen
>>>  
>>> Claus Ibsen
>>> ......................................
>>> Silverbullet
>>> Skovsgårdsvænget 21
>>> 8362 Hørning
>>> Tlf. +45 2962 7576
>>> Web: www.silverbullet.dk
>>>
>>> -----Original Message-----
>>> From: Willem Jiang [mailto:willem.jiang@gmail.com] Sent: 27. 
>>> september 2008 08:30
>>> To: camel-user@activemq.apache.org
>>> Subject: Re: Camel HTTP producer successful on 404?
>>>
>>> I think we should have a list for the response message code which 
>>> just needs to set the fault message or to throw the exception.
>>> I just check the http status codes means.
>>> 1xx information, 2xx successful, 3xx redirection,  4xx client error, 
>>> 5xx server error.
>>> If the response code is in 1xx , 2xx, 3xx. We just put the message 
>>> into exchange out.
>>> If the response code is between 4xx and 5xx. We could throw the 
>>> exception from the http component to trigger the error handler.
>>>
>>> any thought?
>>>
>>> Willem
>>>
>>>
>>>  
>>> harinair wrote:
>>>      
>>>> Thanks a lot, Hadrian and Wilem.
>>>>
>>>> In my case, I have to transfer data to an external consumer using 
>>>> HTTP/HTTPS
>>>> Post. The producer works well for this case. However my requirement 
>>>> is to
>>>> try redelivering(with exponential backoff) for any errors including 
>>>> 404 and
>>>> 500 since it may be a case of consumer's server being down.
>>>>
>>>> I am using something like this:
>>>> errorHandler(deadLetterChannel("jms:redelivery-queue").initialRedeliveryDelay(20000)

>>>>
>>>> .backOffMultiplier(2).maximumRedeliveries(3).useExponentialBackOff());
>>>> from("jms:deliveryqueue").recipientList(header("address")).to("bean:MyBean?method=processIsOK");

>>>> in this the header address contains something like
>>>> https://myconsumer/servlet/CallbackServlet
>>>>
>>>> Now the problem is I find that the HTTP component will not even try
>>>> redelivering for 404 and 401. It acts as if it is a successful 
>>>> transport. I
>>>> understand that I can check whether the delivery has failed or not. 
>>>> I found
>>>> out from HTTP producer code I am even able to check the response 
>>>> code by
>>>> looking at the http.responseCode header (Probably we should update 
>>>> HTTP
>>>> Component doc - I can help). But how can I make Camel try 
>>>> redelivering these
>>>> 404/401 messages?
>>>>
>>>> I am sorry if I am not explaining it properly. Since I am pretty 
>>>> new in
>>>> Camel, probably I am blabbering something that is totally off mark.
>>>>
>>>> Thanks in advance.
>>>> Hari Gangadharan
>>>>
>>>>
>>>> Hadrian Zbarcea wrote:
>>>>            
>>>>> Hi,
>>>>>
>>>>> To add to Willem's comment, there is no point in retrying for 404 
>>>>> for  example, but it makes sense to retry for codes like 500.  
>>>>> That means  that we have to enhance the camel-http component to 
>>>>> create 2 classes  of errors and apply the error handle for some, 
>>>>> but not for others.   This is depended on the cleanup in CAMEL-316 
>>>>> that will only be fully  resolved in the next release, and only 
>>>>> partially (we hope) in 1.5.
>>>>>
>>>>> Thanks for riding the camel,
>>>>> Hadrian
>>>>>
>>>>>
>>>>> On Sep 26, 2008, at 4:00 AM, Willem Jiang wrote:
>>>>>
>>>>>                  
>>>>>> Hi ,
>>>>>>
>>>>>> Current HTTP producer will not retry if the response is 401/404/500.
>>>>>> It just put the response back in the fault message body and it 
>>>>>> will  not trigger the default error handler[1] for retring.
>>>>>>
>>>>>> Your application code should call exchang.isFailed() for 
>>>>>> checking  the fault response.
>>>>>>
>>>>>> For the Camel 1.5 , we are planing to cut a RC next week. I 
>>>>>> don't  think camel-http 1.5-SNAPSHOT can work with camel-core 
>>>>>> 1.4, since  they are some change between the core and http 
>>>>>> component in Camel 1.5.
>>>>>> We are publishing the snapshot every day here[2], please take a 
>>>>>> try :)
>>>>>>
>>>>>> [1] http://activemq.apache.org/camel/error-handler.html
>>>>>> [2] http://people.apache.org/repo/m2-snapshot-repository
>>>>>>
>>>>>> Willem
>>>>>>
>>>>>> harinair wrote:
>>>>>>                        
>>>>>>> Willem:
>>>>>>>
>>>>>>> Thanks a lot for the quick reply. So you mean to say that the

>>>>>>> latest
>>>>>>> SNAPSHOT will mark response != 200 as failed - right? I guess,

>>>>>>> that  also
>>>>>>> means there will be retries by HTTP producer for 500 / 401/ 404

>>>>>>> etc.
>>>>>>>
>>>>>>> If that is the case then it is great. When is the 1.5 release
 
>>>>>>> planned? I am
>>>>>>> planning to go live this week for a small project and I 
>>>>>>> uncovered  this bug
>>>>>>> on a test. Is 1.5 fairly stable? Or is it recommended that I

>>>>>>> use  just the
>>>>>>> camel-http component from the 1.5-SNAPSHOT?
>>>>>>>
>>>>>>> Regards,
>>>>>>> Hari Gangadharan
>>>>>>>
>>>>>>>
>>>>>>> willem.jiang wrote:
>>>>>>>
>>>>>>>                              
>>>>>>>> I just did a fixe on CAMEL-807[1] which relates your issue.
>>>>>>>> Now we will put the response into the fault message if the
 
>>>>>>>> response is not 200.
>>>>>>>> You can know it when you call the exchange.isfailed().
>>>>>>>>
>>>>>>>> Please check out the latest snapshot and feel free to add
your  
>>>>>>>> feed back.
>>>>>>>>
>>>>>>>> [1]https://issues.apache.org/activemq/browse/CAMEL-807
>>>>>>>>
>>>>>>>> Willem
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                                     
>>>>>>>                               
>>>>>                   
>>>>             
>>>       
>>
>>
>>   
>
>


Mime
View raw message