camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Retry based on HTTP response codes
Date Thu, 28 Mar 2013 09:47:23 GMT

See this FAQ

You can also some how to do this on this page

If you have a copy of Camel in Action book, then section 5.5 covers
such a use case to only handle certain conditions from a http response

On Thu, Mar 28, 2013 at 10:02 AM, vss123 <> wrote:
> Oh sorry.. I did not explain clearly.We wanted to throw different exceptions
> for 4xx and 5xx errors and handle them differently.  The problem is that we
> do not know how to get the exception object. We tried this
>     handle[HttpOperationFailedException]{      process(new Processor {
> def process(exchange: Exchange) {          val httpStatusCode =
> exchange.getIn.getHeader(Exchange.HTTP_RESPONSE_CODE)
> if(httpStatusCode.toString.startsWith("5")) throw new
> ServerHttpErrorException
> if(httpStatusCode.toString.startsWith("4")) throw new
> ClientHttpErrorException            throw new Exception        }      })
> }.handled(true)
> The httpStatusCode was /null/. We guess probably because it was thrown and
> not set on the exchange. We tried /getException/.But that, too is /null/
> Then we tried this,
> class ReThrower {  def doIt(httpException: HttpOperationFailedException){
> if(httpException.getStatusCode.toString.startsWith("5")) throw new
> ServerHttpErrorException
> if(httpException.getStatusCode.toString.startsWith("4")) throw new
> ClientHttpErrorException    throw httpException
> }}handle[HttpOperationFailedException]().handled(true).onWhen(bean(classOf[ReThrower],
> "doIt"))
> We got /java.util.NoSuchElementException: head of empty list/ when running.
> Could you give us ideas on how to go about this?
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
Red Hat, Inc.
FuseSource is now part of Red Hat
Twitter: davsclaus
Author of Camel in Action:

View raw message