2

I'm using a route that is requesting a resource over HTTP using the https4 component (camel version 2.14.0). A dead letter channel handles errors by routing failed exchanges to the log endpoint like so:

.to("log:backendFailed?level=WARN&showAll=true")

In case of a gateway timeout (504) a HttpOperationFailedException indicating the error is thrown and the exchange is logged as expected. Since i set showAll=true, all headers of the exchange are logged, including CamelHttpResponseCode. The log looks like this:

CamelFailureEndpoint=https4://backend?httpClient.socketTimeout=70000&httpClient.connectTimeout=70000,
...
CamelToEndpoint=log://backendFailed?level=WARN&showAll=true
...
CamelHttpResponseCode=200, 
CamelHttpUri=https://example.com/myresource, 
...
CaughtExceptionType: org.apache.camel.component.http4.HttpOperationFailedException, 
CaughtExceptionMessage: HTTP operation failed invoking https://example.com/myresource with statusCode: 504, StackTrace: org.apache.camel.component.http4.HttpOperationFailedException: HTTP operation failed invoking https://example.com/myresource with statusCode: 504

Shouldn't the CamelHttpResponseCode header say 504 here?

Prasad Khode
  • 6,602
  • 11
  • 44
  • 59
Claudius B
  • 86
  • 7
  • Have you set handled=true? – Souciance Eqdam Rashti Nov 23 '15 at 11:40
  • No, i did not, because the dead letter channel clears the exception by invoking `setException(null)`. The client does not notice any exceptions that are processed by a dead letter channel. I think this default behaviour is equivalent to setting the handled flag in an Exception Clause (via `onException(Exception.class).handled(true)`). Thats why the `DeadLetterChannelBuilder` does not provide a `handled()` method. – Claudius B Nov 23 '15 at 13:15
  • Well doesn't that mean that the client does receive a HTTP response with 200 OK since the client does not notice any exceptions. The question is whether the CamelHttpResponseCode is for the client who is the caller and not the consumer which receives a 504. You probably need to catch that exception and explicitly set the response code in CamelHttpResponseCode if you want to notify the caller. – Souciance Eqdam Rashti Nov 23 '15 at 13:19
  • 1
    I think a route that involves a HTTP call should set the `CamelHttpResponseCode` header according to the received response. The routes caller wouldn't notice the failure since the exception on the exchange is cleared and no fault flag is set (as desired). However the log would make sense. Wouldn't it be odd if handling an exception involves changing a HTTP status code header? – Claudius B Nov 24 '15 at 07:55
  • Can you post your complete routes here? – Souciance Eqdam Rashti Nov 24 '15 at 07:57

0 Answers0