spring boot @Scheduled stop running

problem:

Spring boot defines the timing function through the annotation @Scheduled, but it will stop running after a while.

the reason:

Generally, the process of executing the Scheduled task has problems such as thread waiting or infinite loop , which causes the Scheduled task to stop.

 If multiple Scheduled tasks are defined, there are threads waiting or an endless loop in a Scheduled task, which will cause all Scheduled tasks to stop executing.

There are many reasons why a certain Scheduled task stops running. It is necessary to analyze specifically what operations are in the Scheduled task. Generally, there are http request operations in the Scheduled task. In the Scheduled task, there is an HttpClient program to request the Server, but the request timeout is not set. Time , when a network abnormality or other conditions cause the request to be interrupted and the http link is not closed normally, the request thread will wait forever, causing the Scheduled task to stop.

solve:

1. If there are multiple Scheduled defined in the program, and the Scheduled stop appears, then you have to comment out the Scheduled tasks one by one, analyze which Scheduled task has a problem, and then analyze the problematic Scheduled task in detail.

2. If there is an http request in the Scheduled task, it is recommended to check whether the request timeout period is set.

reference:

1. There is an FTP request in the scheduled task that causes the scheduled task to stop

https://blog.csdn.net/justin_bob/article/details/104611868

2. http request timeout causes the scheduled task to stop

https://www.cnblogs.com/zj0208/p/7018098.html

https://blog.csdn.net/qq_32157851/article/details/84870403

 

Guess you like

Origin blog.csdn.net/abcdu1/article/details/109730821