title: Spring threads and TaskRejectException when queue is full
body: <p>I'm using Spring to create web application where several users can upload file and with asynchronous task I convert this file.
  Now sometime I receive this exception and tomcat goes down:</p>
  
  <pre><code>Caused by: org.springframework.core.task.TaskRejectedException: Executor [java.util.concurrent.ThreadPoolExecutor@54a611af[Running, pool size = 10, active threads = 10, queued tasks = 10, completed tasks = 230]] did not accept task: org.springframework.aop.interceptor.AsyncExecutionInterceptor$1@598b845a
      at org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.submit(ThreadPoolTaskExecutor.java:284)
      at org.springframework.aop.interceptor.AsyncExecutionAspectSupport.doSubmit(AsyncExecutionAspectSupport.java:189)
      at org.springframework.aop.interceptor.AsyncExecutionInterceptor.invoke(AsyncExecutionInterceptor.java:123)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
      at com.model.ZipAndMat$$EnhancerBySpringCGLIB$$5bcfcf5.createZipAndMat(&lt;generated&gt;)
      at com.services.FleetAcquisitionServicesImpl.uploadFiles(FleetAcquisitionServicesImpl.java:95)
      ... 81 more
  Caused by: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@5a47368c rejected from java.util.concurrent.ThreadPoolExecutor@54a611af[Running, pool size = 10, active threads = 10, queued tasks = 10, completed tasks = 230]
      at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047)
      at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823)
      at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1369)
      at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
      at org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.submit(ThreadPoolTaskExecutor.java:281)
      ... 87 more
  </code></pre>
  
  <p>How can I manage this problem? I thought to increase queue size and when it is full the other task should wait until queue has a free slot.
  Thanks</p>