title: Spring @Async method inside a Service
body: <p>I have this service bean with a <em>sync</em> method calling the internal <em>async</em> method:</p>
  <pre><code>@Service
  public class MyService {
      
      public worker() {
          asyncJob();
      }
      
      @Async
      void asyncJob() {
          ...
      }
      
  }
  </code></pre>
  <p>The trouble is that the <code>asyncJob</code> is not really called in <em>async</em> way.
  I found that this doesn't work because an internal call skips the <strong>AOP proxy</strong>.</p>
  <p>So I try to <strong>self-refer</strong> the bean:</p>
  <pre><code>@Service
  public class MyService {
      
      MyService mySelf;
  
      @Autowired
      ApplicationContext cnt;
  
      @PostConstruct
      public void init() {
          mySelf=(MyService)cnt.getBean(&quot;myService&quot;);
      }
      
      
      public void worker() {
          mySelf.asyncJob();
      }
      
      @Async
      void asyncJob() {
          ...
      }
      
  }
  </code></pre>
  <p><strong>It fails</strong>. Again no <em>async</em> call.</p>
  <p>So I tried to <strong>divide it</strong> in two beans:</p>
  <pre><code>@Service
  public class MyService {
  
      @Autowired
      MyAsyncService myAsyncService;
  
      public void worker() {
          myAsyncService.asyncJob();
      }
  }
  
  @Service
  public class MyAsyncService {
  
      @Async
      void asyncJob() {
          ...
      }
      
  }
  </code></pre>
  <p><strong>Fails again</strong>.</p>
  <br>
  <p>The only working way is to call it from a <strong>Controller Bean</strong>:</p>
  <pre><code>@Controller
  public class MyController {
  
      @Autowired
      MyAsyncService myAsyncService;
  
      @RequestMapping(&quot;/test&quot;)
      public void worker() {
          myAsyncService.asyncJob();
      }
  
  }
  
  @Service
  public class MyAsyncService {
  
      @Async
      public void asyncJob() {
          ...
      }
      
  }
  </code></pre>
  <p>But in this case it is a service job. Why I cannot call it from a <em>service</em>?</p>