title: org.springframework.core.task.TaskRejectedException while listening for SQS queue?
body: <p>I create a basic workflow of consuming messages from <code>SQS</code> with <code>@SqsListener</code>. It works fine but I constantly get tons of similar messages:</p>
  
  <blockquote>
    <p>org.springframework.core.task.TaskRejectedException: Executor
    [java.util.concurrent.ThreadPoolExecutor@372b568[Running, pool size =
    3, active threads = 3, queued tasks = 0, completed tasks = 0]] did not
    accept task:
    org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer$SignalExecutingRunnable@4c30c2f9
      at
    org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.execute(ThreadPoolTaskExecutor.java:317)
    ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]     at
    org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer$AsynchronousMessageListener.run(SimpleMessageListenerContainer.java:286)
    ~[spring-cloud-aws-messaging-2.1.0.RELEASE.jar:2.1.0.RELEASE]     at
    java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    [na:1.8.0_171]    at
    java.util.concurrent.FutureTask.run(FutureTask.java:266)
    [na:1.8.0_171]    at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    [na:1.8.0_171]    at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    [na:1.8.0_171]    at java.lang.Thread.run(Thread.java:748)
    [na:1.8.0_171] Caused by:
    java.util.concurrent.RejectedExecutionException: Task
    org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer$SignalExecutingRunnable@4c30c2f9
    rejected from java.util.concurrent.ThreadPoolExecutor@372b568[Running,
    pool size = 3, active threads = 3, queued tasks = 0, completed tasks =
    0]    at
    java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063)
    ~[na:1.8.0_171]   at
    java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)
    [na:1.8.0_171]    at
    java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)
    [na:1.8.0_171]    at
    org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.execute(ThreadPoolTaskExecutor.java:314)
    ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]     ... 6 common frames
    omitted</p>
  </blockquote>
  
  <p>My configuration bean:</p>
  
  <pre><code>@EnableSqs
  @Configuration
  public class AmazonSqsConfiguration {
  
      @Value("${aws.sqs.accessKey}")
      private String accessKey;
  
      @Value("${aws.sqs.secretKey}")
      private String secretKey;
  
      @Value("${aws.sqs.region}")
      private String region;
  
      @Value("${aws.sqs.url}")
      private String url;
  
      @Bean
      public AmazonSQSAsync amazonSqs() {
          AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
          AWSStaticCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
          return AmazonSQSAsyncClientBuilder.standard()
                  .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(url, region))
                  .withCredentials(credentialsProvider)
                  .build();
      }
  
  }
  </code></pre>
  
  <p>My consumer is the following:</p>
  
  <pre><code>@SqsListener(value = "my-queue", deletionPolicy = SqsMessageDeletionPolicy.ON_SUCCESS)
      public void processSubscription(String xmlNotification) {/* Message processor */}
  </code></pre>
  
  <p>Is it possible to remove them by re configuring <code>@Bean</code>? What is the root cause of the issue and how to fight with it? </p>
  
  <p>I tried to find solution by natural search and encountered with the <a href="https://stackoverflow.com/questions/38259400/threadpoolexecutor-taskrejectedexception-from-executor">following answer</a>. It doesn't work for me, since I don't have <code>JMS</code>. I couldn't debug because I don't even know what to debug.</p>