title: @Transactional on @Async methods in Spring
body: <p>I have a scenario where I call three <code>@Transactional @Async</code> methods. Everything works fine except all three methods have their own transaction context. I want to execute them in calling method's transaction context.</p>
  
  <p>My Calling method is like this:</p>
  
  <pre><code> @Transactional
   public void execute(BillingRequestDto requestDto) {
          try {
              LOGGER.info("Start Processing Request : {}", requestDto.getId());
              List&lt;Future&lt;?&gt;&gt; futures = new ArrayList&lt;&gt;();
              futures.add(inboundProcessingService.execute(requestDto));
              futures.add(orderProcessingService.execute(requestDto));
              futures.add(waybillProcessingService.execute(requestDto));
              futures.stream().parallel().forEach(future -&gt; {
                  try {
                      future.get();
                  } catch (Exception e) {
                      futures.forEach(future1 -&gt; future1.cancel(true));
                      throw new FBMException(e);
                  }
              });
              requestDto.setStatus(RequestStatus.SUCCESS.name());
              requestDto.setCompletedAt(new Date());   
              LOGGER.info("Done Processing Request : {}", requestDto.getId());
  
          } catch (Exception e) {
              requestDto.setStatus(RequestStatus.FAIL.name());
              requestDto.setCompletedAt(new Date());
              throw new FBMException(e);
          } 
      }
  </code></pre>
  
  <p>And all called methods are annotated with <code>@Async</code> and <code>@Transactional</code>.</p>
  
  <pre><code>@Transactional
  @Async
  public Future&lt;Void&gt; execute(BillingRequestDto requestDto) {
      LOGGER.info("Start Waybill Processing {}", requestDto.getId());
      long count = waybillRepository.deleteByClientNameAndMonth(requestDto.getClientName(), requestDto.getMonth());
      LOGGER.info("Deleted  {} Records for Request {} ", count, requestDto.getId());
      try (InputStream inputStream = loadCsvAsInputStream(requestDto)) {
          startBilling(requestDto, inputStream);
      } catch (IOException e) {
          LOGGER.error("Error while processing");
          throw new FBMException(e);
      }
      LOGGER.info("Done Waybill Processing {}", requestDto.getId());
      return null;
  }
  </code></pre>
  
  <p>Implementation for all three methods is more or less same.</p>
  
  <p>Now if there is a failure in any of these methods then transaction in rolled-back for that method only.</p>
  
  <p>My requirement is to run all three methods in calling methods transaction context so any exception in one method will rollback all three methods.</p>
  
  <p>This scenario works well if I disable <code>@Async</code>. There are time taking methods so I want them to run in parallel.</p>
  
  <p>Please suggest any solution for this.</p>