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 420d9f4adc..8a9a4ff877 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,8 +1,6 @@ package io.metersphere.performance.engine.producer; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.metersphere.commons.utils.LogUtil; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Service; @@ -11,26 +9,16 @@ import javax.annotation.Resource; @Service public class LoadTestProducer { + private static final String SEPARATOR = " "; @Value("${kafka.log.topic}") private String topic; @Resource private KafkaTemplate kafkaTemplate; - @Resource - private ObjectMapper objectMapper; public void sendMessage(String reportId) { - Log log = Log.builder() - .reportId(reportId) - .resourceId("none") - .resourceIndex(0) - .content("Notifying test listeners of end of test") - .build(); - - try { - this.kafkaTemplate.send(topic, objectMapper.writeValueAsString(log)); - } catch (JsonProcessingException e) { - LogUtil.error("发送停止消息失败", e); - } + String[] contents = new String[]{reportId, "none", "0", "Notifying test listeners of end of test"}; + String log = StringUtils.join(contents, SEPARATOR); + this.kafkaTemplate.send(topic, log); } } diff --git a/backend/src/main/java/io/metersphere/performance/engine/producer/Log.java b/backend/src/main/java/io/metersphere/performance/engine/producer/Log.java deleted file mode 100644 index 813d932c20..0000000000 --- a/backend/src/main/java/io/metersphere/performance/engine/producer/Log.java +++ /dev/null @@ -1,13 +0,0 @@ -package io.metersphere.performance.engine.producer; - -import lombok.Builder; -import lombok.Data; - -@Data -@Builder -public class Log { - private String reportId; - private String resourceId; - private int resourceIndex; - private String content; -}