title: Spring Task Async and Delayed
body: <p>I need to do onething that I don't know wich is the best practice to this.</p>
  
  <p>After I send one request to an especific service, this one returns OK and queue my request. I have a callback service that is used to notify when it ends. </p>
  
  <p>The problem is that the whole process can take a long time and over without notify anything and after that I need to consider a timeout.</p>
  
  <p>The application is SpringBoot APP and I was considering to use the annotations @EnableAsync and @Async on a service method with a Sleep time.</p>
  
  <pre><code>@Configuration
  @EnableAsync
  public class AsyncConfiguration implements AsyncConfigurer {
  
      @Override
      public Executor getAsyncExecutor() {
  
          ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
          executor.setCorePoolSize(2);
          executor.setMaxPoolSize(10);
          executor.setQueueCapacity(500);
          executor.setThreadNamePrefix("TIMCLL-");
          executor.initialize();
          return executor;
  
      }
  
      @Override
      public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
          // TODO Auto-generated method stub
          return null;
      }
  
  }
  </code></pre>
  
  <p>.
  .
  .</p>
  
  <pre><code>@Async
  public void verifyStatusTimPayment() throws InterruptedException {
  
      Thread.sleep(5000);
      logger.info( "Executed after 5s " +  new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").format(new Date())); 
  
  }
  </code></pre>
  
  <p>The verification needs to be done 15 minutes after the request and have to occur just one time per request.</p>
  
  <p>How can I do this without make a Thread.sleep ?????</p>