title: Stop Camel after too many retries
body: <p>I am trying to implement more advanced Apache Camel error handling: 
  in case if there are too many pending retries then stop processing at all and log all collected exceptions somewhere. </p>
  
  <p>First part (stop on too many retries) is already implemented by following helper method, that gets size of retry queue and I just stop context if queue is over some limit:</p>
  
  <pre><code>    static Long getToRetryTaskCount(CamelContext context)   {
      Long retryTaskCount = null;
      ScheduledExecutorService errorHandlerExecutor = context.getErrorHandlerExecutorService();
  
  
      if (errorHandlerExecutor instanceof SizedScheduledExecutorService)
      {
          SizedScheduledExecutorService svc = (SizedScheduledExecutorService) errorHandlerExecutor;
          ScheduledThreadPoolExecutor executor = svc.getScheduledThreadPoolExecutor();
          BlockingQueue&lt;Runnable&gt; queue = executor.getQueue();
          retryTaskCount = (long) queue.size();           
      }
      return retryTaskCount;
  }
  </code></pre>
  
  <p>But this code smells to me and I don't like it and also I don't see here any way to collect the exceptions caused all this retries.  </p>