Spring @Async ignored
@Async
(as well as @Transactional
and other similar annotations) will not work when the method is invoked via this
(on when @Async
is used for private methods*), as long as you do not use real AspectJ compiletime or runtime weaving.
*the private method thing is: when the method is private, then it must been invoked via this
- so this is more the consequence then the cause
So change your code:
@Servicepublic class DefaultNotificationProcessor implements NotificationProcessor { @Resource private DefaultNotificationProcessor selfReference; @Override public void process(Notification notification) { selfReference.processAsync(notification); } //the method must not been private //the method must been invoked via a bean reference @Async void processAsync(Notification notification) { // Heavy processing }}
See also the answers for: Does Spring @Transactional attribute work on a private method? -- this is the same problem