fix: 性能测试消息发送失败

This commit is contained in:
wenyann 2020-11-05 14:54:39 +08:00
parent 9aeed6b027
commit e54bd0dc14
1 changed files with 19 additions and 20 deletions

View File

@ -47,10 +47,9 @@ public class PerformanceNoticeTask {
} }
public void registerNoticeTask(LoadTestReportWithBLOBs loadTestReport) { public void registerNoticeTask(LoadTestReportWithBLOBs loadTestReport) {
executorService.submit(() -> { int count = 20;
while (isRunning) { while (count-- > 0) {
LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReport.getId()); LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReport.getId());
if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Completed.name())) { if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Completed.name())) {
isRunning = false; isRunning = false;
sendSuccessNotice(loadTestReportFromDatabase); sendSuccessNotice(loadTestReportFromDatabase);
@ -61,13 +60,13 @@ public class PerformanceNoticeTask {
sendFailNotice(loadTestReportFromDatabase); sendFailNotice(loadTestReportFromDatabase);
return; return;
} }
count--;
try { try {
Thread.sleep(1000 * 60);// 每分钟检查 loadtest 的状态 Thread.sleep(1000 * 4L);// 每分钟检查 loadtest 的状态
} catch (InterruptedException e) { } catch (InterruptedException e) {
LogUtil.error(e); LogUtil.error(e);
} }
} }
});
} }
public void sendSuccessNotice(LoadTestReportWithBLOBs loadTestReport) { public void sendSuccessNotice(LoadTestReportWithBLOBs loadTestReport) {