title: shutting down ExecutorService in a spring boot Rest API
body: <p>Am building a spring boot rest api application deployed on weblogic 12c.
  One of my requirement is to  run some long running tasks on every incoming request.
  An incoming rest request could result into multiple asynchronous task executions.</p>
  
  <p>Since I dont care for the response and nor any exceptions that will result from these tasks I chose to use the ExecutorService and not Callable or CompletableFuture.</p>
  
  <pre><code>ExecutorService executorService =
    Executors.newFixedThreadPool(2, new CustomizableThreadFactory("-abc-"));
  </code></pre>
  
  <p>Then for the incoming request that I receive in controller run two for loops and assign those tasks to the ExecutorService:</p>
  
  <pre><code>for (final String orderId : orderIds) {
          for (final String itemId : itemIds) {               
              exec.execute(new Runnable() {
                  public void run() { 
                      try {           
                           //call database operation
                      }catch(Throwable t) {
                         logger.error("EXCEPTION with {} , {}" ,orderId,itemId 
                      )
                  }   
              });
          }//for          
      }//for
  </code></pre>
  
  <p>My question is regarding shutting down of the ExecutorService.
  I am aware about graceful shutdown ( shutdown ) a hybrid shutdown ( awaitTermination ) or an abrupt shutdown ( shutdownNow )</p>
  
  <p>what would be the preferred approach between the three for a rest api application ?</p>
  
  <p>also is there any limit on how many thread pools can get created viz a viz as the number of ExecutorService thread pools getting created will be driven by the number of incoming requests  </p>