REQ-2481: 处理关闭

This commit is contained in:
yanglin 2024-05-31 14:36:14 +08:00
parent 0ef8101197
commit 0e1a0ec0b8
2 changed files with 9 additions and 0 deletions

View File

@ -31,6 +31,8 @@ import java.util.function.Supplier;
@RequiredArgsConstructor
public class ScanAndSendService {
static volatile boolean isShutdown = false;
private final ApplicationContext applicationContext;
private final SendJobInfoMapper sendJobInfoMapper;
private final ForkJoinPool threadPool = new ForkJoinPool(15);
@ -140,4 +142,9 @@ public class ScanAndSendService {
return sendJobInfo;
}
static {
Runtime.getRuntime().addShutdownHook(new Thread(() -> isShutdown = true));
}
}

View File

@ -39,6 +39,8 @@ class SendManager {
public boolean isInterrupted() {
if (execInterrupted || someoneJumpedTheQueue)
return true;
if (ScanAndSendService.isShutdown)
return true;
if (Thread.currentThread().isInterrupted())
return true;
if (!cfg.isEnableJumpTheQueue())