fix(性能测试): 手动停止测试时发送停止消息到data-streaming
This commit is contained in:
parent
cd7dff5fb7
commit
7d6d5bc5d8
|
@ -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<String, Object> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue