LowCool
LowCool

Reputation: 1411

camel body is set with request instead of response

I am stuck in bit weird situation my camel route looks like this

 from("direct:start")
  .doTry()
      .to("http://myedpoint.com")
      .log(LoggingLevel.DEBUG, "com.mycompany.MyCoolRoute", " ${body}")
  .doCatch(Exception.class)
     .log(LoggingLevel.DEBUG, "com.mycompany.MyCoolRoute", " ${body}")
     .to("bean:foo");

Now what happened in my success scenario my body is logged with response I got from endpoint but in failure scenario though my endpoint is giving me failure response body is logged with my request that I have sent to end point can any please explain me why this happened and how can I solve it?

Upvotes: 0

Views: 677

Answers (1)

anon
anon

Reputation:

Looking at the documentation for the http component, this is expected behavior. If you look at the details for option throwExceptionOnFailure, it defaults to true, meaning that an undesirable status code will result in an exception being thrown and the response being tossed out. Setting this option to false will alter this behavior so the response is kept. The example code in the documentation shows how this is done.

Upvotes: 1

Related Questions