title: Custom ThreadPoolTaskExecutor with Spring Boot Async
body: <p>I have a Spring Boot application which is responsible for answering requests via REST. I also push metrics about my application call. Since this is a separate task and I have to response users immediately, I want to make that metrics publishing asynchronously. So I've used that:</p>
  
  <pre><code>ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
  executor.setCorePoolSize(2);
  executor.setMaxPoolSize(2);
  executor.setQueueCapacity(500);
  executor.setThreadNamePrefix("MyApp-");
  executor.initialize();
  return executor;
  </code></pre>
  
  <p>However, this one uses <code>SimpleAsyncTaskExecutor</code> and does not reuse any threads.</p>
  
  <p>1) How can I use <code>ConcurrentTaskExecutor</code> instead of <code>SimpleAsyncTaskExecutor</code>?</p>
  
  <p>2) Which implementation could best fit for my needs? </p>