Apache Camel: camel-http, Apache HttpClient, and Retry Attempts
Feb 6 2018

Morning! Here's a quick tip on camel-http and proper retry logic within error handling. Under the hood, camel-http uses Apache's HttpClient, which provides its own retry logic by default. Adding Camel's onException redeliveries on top of that ends up multiplying the attempts.


By default, the above will actually be reattempted 9 times, not 3!

So, we need to choose one or the other. I'd recommend disabling the retries on HttpClient, allowing the Camel redelivery policies to be setup like all the others (consistency FTW). That requires registering a HttpClientConfigurer bean, then referring to it on your http step.

public HttpClientConfigurer noRetryHttpConfigurer() {
  return new HttpClientConfigurer() {
    public void configureHttpClient(HttpClient client) {
      client.getParams().setParameter("http.method.retry-handler", new DefaultHttpMethodRetryHandler(0, false));