title: Queue size exceeds from configured max queue capacity in ThreadPoolTaskExecutor used in spring boot
body: <p>Please Look at this below piece of code:</p>
  <pre><code>@Autowired  
  private ThreadPoolTaskExecutor executor;  
    
  @PostConstruct
  public void setupTaskExecutor() {
      this.executor.setCorePoolSize(getExecutorCorePoolSize());
      this.executor.setMaxPoolSize(getExecutorMaxPoolSize());
      this.executor.setQueueCapacity(getExecutorMaxQueueCapacity());
  }  
    
  public ZoneDetail getZoneDetails(ConfigRequest configRequest) {
  
      LOGGER.debug(&quot;QueueSize = {}&quot;, executor.getThreadPoolExecutor().getQueue().size());
      LOGGER.debug(&quot;PoolSize = {}&quot;, executor.getPoolSize());      
  
      Future&lt;ZoneDetail&gt; future = executor.submit(() -&gt; {
          return getPrimaryProvider(context).getZoneDetails(context, 
          configRequest);
      });
  
      try {
          ZoneDetail zoneDetail = future.get(getPrimaryProviderTimeout(),
          TimeUnit.MILLISECONDS);
      } catch (ExecutionException | TimeoutException e) { 
          // fetch data from secondary provider
      }
          
  }  
  </code></pre>
  <p>My configured values are<br />
  <strong>core-pool-size=4<br />
  max-pool-size=16<br />
  max-queue-capacity=5</strong></p>
  <p>I run a PT using SoapUI with following parameters,</p>
  <pre><code>Threads: 20  Strategy: Simple Test Delay: 0 Limit: 5 seconds
  </code></pre>
  <p>i.e. I am hitting 20 Threads at a time for 5 seconds.</p>
  <p>In the console, I see <strong>QueueSize = 15</strong> i.e. my queue size exceeds the configured max queue capacity 5. And <strong>PoolSize = 4</strong> i.e. my pool size never exceeds core pool size since extra threads are going into queue.</p>
  <p><strong>Note:</strong> I am hitting a REST API that calls getZoneDetails() method</p>
  <p><strong>How is it happening? What am I doing wrong ?</strong></p>