@Async
method in @Service
annotated class in standalone Spring Boot application doesn\'t run asynchronously. What am I doing wrong?
When I
Workaround is:
@EnableAsync
@Service("ip-service")
public class ImageProcessorService implements IIMageProcessorService {
@Autowired
@Qualifier("ip-service")
ImageProcessorService ipService;
public void downloadAllImages(Run lastRun) {
// this method calls downloadAnSave() in loop and should run asynchronously....
ipService.downloadAnSave(productId, imageUrl);
}
@Async
@Override
public boolean downloadAnSave(String productId, String imageUrl) {
//
}
}
With such approach you call method of proxy, not the class instance. The same approach can be used with other tools working with proxies, e.g. @Transactional etc.