diff --git a/backend/src/main/java/io/metersphere/api/exec/utils/GenerateHashTreeUtil.java b/backend/src/main/java/io/metersphere/api/exec/utils/GenerateHashTreeUtil.java index 245231c2b7..bde94162a3 100644 --- a/backend/src/main/java/io/metersphere/api/exec/utils/GenerateHashTreeUtil.java +++ b/backend/src/main/java/io/metersphere/api/exec/utils/GenerateHashTreeUtil.java @@ -64,7 +64,6 @@ public class GenerateHashTreeUtil { } } catch (Exception e) { LogUtil.error(e); - LogUtil.error(e); } } diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APISingleResultListener.java b/backend/src/main/java/io/metersphere/api/jmeter/APISingleResultListener.java index 3c81743e70..4550de466c 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APISingleResultListener.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APISingleResultListener.java @@ -15,6 +15,9 @@ import org.apache.commons.lang3.StringUtils; import java.util.Map; public class APISingleResultListener extends MsExecListener { + + private ApiExecutionQueueService apiExecutionQueueService; + @Override public void handleTeardownTest(ResultDTO dto, Map kafkaConfig) { LoggerUtil.info("处理单条执行结果报告【" + dto.getReportId() + " 】,资源【 " + dto.getTestId() + " 】"); @@ -39,14 +42,17 @@ public class APISingleResultListener extends MsExecListener { // 整体执行结束更新资源状态 CommonBeanFactory.getBean(TestResultService.class).testEnded(dto); + if (apiExecutionQueueService == null) { + apiExecutionQueueService = CommonBeanFactory.getBean(ApiExecutionQueueService.class); + } LoggerUtil.info("执行队列处理:" + dto.getQueueId()); if (StringUtils.isNotEmpty(dto.getQueueId())) { - CommonBeanFactory.getBean(ApiExecutionQueueService.class).queueNext(dto); + apiExecutionQueueService.queueNext(dto); } // 更新测试计划报告 if (StringUtils.isNotEmpty(dto.getTestPlanReportId())) { LoggerUtil.info("Check Processing Test Plan report status:" + dto.getQueueId() + "," + dto.getTestId()); - CommonBeanFactory.getBean(ApiExecutionQueueService.class).testPlanReportTestEnded(dto.getTestPlanReportId()); + apiExecutionQueueService.testPlanReportTestEnded(dto.getTestPlanReportId()); } } catch (Exception e) { LoggerUtil.error(e); diff --git a/backend/src/main/java/io/metersphere/api/jmeter/MsKafkaListener.java b/backend/src/main/java/io/metersphere/api/jmeter/MsKafkaListener.java index 510f94dc1c..a82e7886c6 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/MsKafkaListener.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/MsKafkaListener.java @@ -22,6 +22,8 @@ import javax.annotation.Resource; @Service public class MsKafkaListener { public static final String CONSUME_ID = "ms-api-exec-consume"; + @Resource + private ApiExecutionQueueService apiExecutionQueueService; @KafkaListener(id = CONSUME_ID, topics = KafkaConfig.TOPICS, groupId = "${spring.kafka.consumer.group-id}") public void consume(ConsumerRecord record) { @@ -30,14 +32,15 @@ public class MsKafkaListener { if (testResult != null && testResult.getArbitraryData() != null && testResult.getArbitraryData().containsKey("TEST_END") && (Boolean) testResult.getArbitraryData().get("TEST_END")) { LoggerUtil.info("报告 【 " + testResult.getReportId() + " 】资源 " + testResult.getTestId() + " 整体执行完成"); testResultService.testEnded(testResult); + LoggerUtil.info("执行队列处理:" + testResult.getQueueId()); - CommonBeanFactory.getBean(ApiExecutionQueueService.class).queueNext(testResult); + apiExecutionQueueService.queueNext(testResult); // 全局并发队列 PoolExecBlockingQueueUtil.offer(testResult.getReportId()); // 更新测试计划报告 if (StringUtils.isNotEmpty(testResult.getTestPlanReportId())) { LoggerUtil.info("Check Processing Test Plan report status:" + testResult.getQueueId() + "," + testResult.getTestId()); - CommonBeanFactory.getBean(ApiExecutionQueueService.class).testPlanReportTestEnded(testResult.getTestPlanReportId()); + apiExecutionQueueService.testPlanReportTestEnded(testResult.getTestPlanReportId()); } } else { // 更新报告最后接收到请求的时间