From 7d6d5bc5d8af2e7de5dc9afe68e2ffd8fa177ed3 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Tue, 9 Feb 2021 14:49:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E5=81=9C=E6=AD=A2=E6=B5=8B=E8=AF=95=E6=97=B6?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=81=9C=E6=AD=A2=E6=B6=88=E6=81=AF=E5=88=B0?= =?UTF-8?q?data-streaming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/producer/LoadTestProducer.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/performance/engine/producer/LoadTestProducer.java b/backend/src/main/java/io/metersphere/performance/engine/producer/LoadTestProducer.java index fd53f98380..c8a6bf3c62 100644 --- a/backend/src/main/java/io/metersphere/performance/engine/producer/LoadTestProducer.java +++ b/backend/src/main/java/io/metersphere/performance/engine/producer/LoadTestProducer.java @@ -1,6 +1,8 @@ package io.metersphere.performance.engine.producer; -import com.alibaba.fastjson.JSON; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.metersphere.commons.utils.LogUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Service; @@ -14,11 +16,17 @@ public class LoadTestProducer { private String topic; @Resource private KafkaTemplate kafkaTemplate; + @Resource + private ObjectMapper objectMapper; public void sendMessage(String reportId) { Metric metric = new Metric(); metric.setReportId(reportId); metric.setThreadName("tearDown Thread Group"); // 发送停止消息 - this.kafkaTemplate.send(topic, JSON.toJSONString(metric)); + try { + this.kafkaTemplate.send(topic, objectMapper.writeValueAsString(metric)); + } catch (JsonProcessingException e) { + LogUtil.error("发送停止消息失败", e); + } } }