Minor change. I renamed the option to throwExceptionOnFailure.

On Thu, Apr 2, 2009 at 4:48 PM, Claus Ibsen <claus.ib...@gmail.com> wrote:
> Hi Peter
>
> I have created a more simple example
> http://svn.apache.org/viewvc?view=rev&revision=761307
>
> And the wiki page has been updated as well
> http://cwiki.apache.org/confluence/display/CAMEL/HTTP
>
> On Thu, Apr 2, 2009 at 4:02 PM, Claus Ibsen <claus.ib...@gmail.com> wrote:
>> Hi Peter
>>
>> I have create an unit test to demonstrate this
>> http://svn.apache.org/viewvc?view=rev&revision=761300
>>
>> However I also think it was a bit cumbersome to do it nicely, so I
>> have logged a RFE:
>> https://issues.apache.org/activemq/browse/CAMEL-1512
>>
>> So we can let the http producer return any response in the exchange
>> instead of throwing exceptions for failed error codes.
>>
>>
>> On Thu, Apr 2, 2009 at 3:16 PM, Peter Maas <pfmm...@gmail.com> wrote:
>>> I've tried to implement your solution, but failed to do so correctly. No
>>> matter where I put the error handler, the route stops processing after
>>> receiving a 404. Could anyone give me an example on how to act on a http 404
>>> response?
>>>
>>>
>>> On Mar 30, 2009, at 16:48 , Claus Ibsen wrote:
>>>
>>>> Hi
>>>>
>>>>
>>>>
>>>> On Mon, Mar 30, 2009 at 4:33 PM, Peter Maas <pfmm...@gmail.com> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> according to the documentation of the HTTP component it should be
>>>>> possible
>>>>> to retrieve the response code if the call fails. I fail to grasp how to
>>>>> exactly use this.  I wanted to use the enrich pattern to call an external
>>>>> http based service to enrich the current message:
>>>>>
>>>>>               from("file:src/data")
>>>>>                       .setHeader("id",
>>>>> vpro.xpath("//vpro:schedule/@channel", String.class))
>>>>>                       .enrich("direct:couchdb", new
>>>>> AggregationStrategy(){
>>>>>                               public Exchange aggregate(Exchange
>>>>> original,
>>>>> Exchange resource) {
>>>>>                                       Message responseOut =
>>>>> resource.getOut();
>>>>>                                       int responseCode =
>>>>> responseOut.getHeader(HttpConstants.HTTP_RESPONSE_CODE, Integer.class);
>>>>>                                       System.out.println(responseCode + "
>>>>> "
>>>>> + responseOut.getBody(String.class));
>>>>>                                       return original;
>>>>>                               }
>>>>>                       }
>>>>>                       )
>>>>>                       .to("...")
>>>>>
>>>>>
>>>>> and in the resource route:
>>>>>
>>>>>               from("direct:couchdb")
>>>>>                       .setBody(constant(""))
>>>>>                       .setHeader("CamelHttpMethod", constant("GET"))
>>>>>                       .setHeader(HttpConstants.HTTP_URI,
>>>>> constant(LOCAL_DB).append(header("id")))
>>>>>                       .to("http://couchdb";);
>>>>>
>>>>> The executed HTTP GET arrives at the server as I expected, since it
>>>>> doesn't
>>>>> know the resource it returns a 404. The 404 is thrown as a
>>>>> HttpOperationFailedException which triggers a retry...
>>>>>
>>>>> I'm probably missing something vital, but would really like a push in the
>>>>> right direction here!
>>>>
>>>> Ah since you use a sub route before doing the actual HTTP invocation
>>>> you should disable the error handler to avoid it doing a retry
>>>> from("direct:crouchdb").errorHandler(noErrorHandler())....
>>>>
>>>> In fact you can configure it as a global to avoid the default error
>>>> handler all together.
>>>>
>>>> Its up for debate in Camel 2.0 how the defaults for error handling should
>>>> be.
>>>>
>>>> We will later start a separate thread for this as a open discussion.
>>>> But we would definitly value the community feedback on this one.
>>>>
>>>>
>>>>>
>>>>> thanks in advance,
>>>>>
>>>>> Peter
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> Apache Camel Committer
>>>>
>>>> Open Source Integration: http://fusesource.com
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Twitter: http://twitter.com/davsclaus
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>> Apache Camel Reference Card:
>> http://refcardz.dzone.com/refcardz/enterprise-integration
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> Apache Camel Reference Card:
> http://refcardz.dzone.com/refcardz/enterprise-integration
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration

Reply via email to