0

I am using @Async tag inside a method in Anonymous class. Does Spring AOP support this:

  private void scheduleProcessing(final SomePojo somepojo) {
      taskScheduler.schedule(new Runnable() {
          @Override
          @Async("myThreadPoolTaskExecutor")
          public void run() {
            // biz logic
          }
      }, 20, TimeUnit.SECONDS);
  }
Cœur
  • 37,241
  • 25
  • 195
  • 267
David John
  • 179
  • 1
  • 11
  • Apparently methods denoted with spring annotations like Async, Transactional etc should be called from outside the class (AOP Proxy). Here run will be called somewhere internally when the Thread starts – David John Jul 20 '17 at 05:08

1 Answers1

0

Apparently methods denoted with spring annotations like @Async, @Transactional etc should be called from outside the class (AOP Proxy). Here run will be called somewhere internally when the Thread starts hence not applying the async-ness to the method.

David John
  • 179
  • 1
  • 11