英文:
Spring Boot @Async: Pause Execution
问题
在Spring Boot中,是否有一种方法可以在运行时暂停使用@Async注解的方法的执行,直到满足某个条件或经过一段时间?
在Spring Boot微服务中,我有一个REST控制器,同步接收请求,然后调用一个使用@Async注解的委托来运行资源密集型任务。
每天,该微服务都需要读取大型CSV文件并对其进行解析,这大约需要1-2分钟。在此期间,我希望暂停异步方法的执行,但保留队列,以便在所有读取和解析完成后,它将继续运行异步方法。
英文:
In Spring Boot is there a way to pause the execution of @Async Annotated Methods at runtime until a condition is met or for a duration?
In a Spring Boot Microservice I have a REST Controller which accepts request synchronously and then calls a delegate annotated with @Async to run resource heavy jobs.
Every day the Microservice has to read large csv files and parse them, which takes about 1-2 Minutes. For this period I would like to pause the execution of the Async Method but keep the queue, so that as soon as all the reading and parsing is done, it will then continue to run the Async methods.
专注分享java语言的经验与见解,让所有开发者获益!
评论