From fbdb707d7a9fa490956d9d27584b7ff9f34f1c55 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 19 Apr 2021 09:53:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8=E5=8C=96?= =?UTF-8?q?=E5=A4=9A=E8=8A=82=E7=82=B9=E6=89=A7=E8=A1=8C=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/metersphere/api/jmeter/MsKafkaListener.java | 3 ++- .../api/service/ApiDefinitionExecResultService.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 76cdbba766..442190c3f0 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/MsKafkaListener.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/MsKafkaListener.java @@ -31,8 +31,9 @@ import java.util.Map; @Service public class MsKafkaListener { public static final String TOPICS = "ms-api-exec-topic"; + public static final String CONSUME_ID = "ms-api-exec-consume"; - @KafkaListener(topics = TOPICS) + @KafkaListener(id = CONSUME_ID, topics = TOPICS, groupId = "${spring.kafka.consumer.group-id}") public void consume(ConsumerRecord record) { LogUtil.info("接收到执行结果开始存储"); this.save(record.value()); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java index 7825a6e6e8..4d2b25bfa9 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java @@ -55,7 +55,7 @@ public class ApiDefinitionExecResultService { ApiDefinitionExecResult saveResult = new ApiDefinitionExecResult(); saveResult.setId(UUID.randomUUID().toString()); saveResult.setCreateTime(item.getStartTime()); - saveResult.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); + saveResult.setUserId(result.getUserId()); saveResult.setName(item.getName()); if (item.getName().indexOf("<->") != -1) { saveResult.setName(item.getName().substring(0, item.getName().indexOf("<->")));