mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-11-29 18:48:13 +08:00
refactor(性能测试): 手动停止测试发送通知修改
This commit is contained in:
parent
198bb154c4
commit
c91cf585fa
@ -1,8 +1,6 @@
|
|||||||
package io.metersphere.performance.engine.producer;
|
package io.metersphere.performance.engine.producer;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.kafka.core.KafkaTemplate;
|
import org.springframework.kafka.core.KafkaTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -11,26 +9,16 @@ import javax.annotation.Resource;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class LoadTestProducer {
|
public class LoadTestProducer {
|
||||||
|
private static final String SEPARATOR = " ";
|
||||||
|
|
||||||
@Value("${kafka.log.topic}")
|
@Value("${kafka.log.topic}")
|
||||||
private String topic;
|
private String topic;
|
||||||
@Resource
|
@Resource
|
||||||
private KafkaTemplate<String, Object> kafkaTemplate;
|
private KafkaTemplate<String, Object> kafkaTemplate;
|
||||||
@Resource
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
public void sendMessage(String reportId) {
|
public void sendMessage(String reportId) {
|
||||||
Log log = Log.builder()
|
String[] contents = new String[]{reportId, "none", "0", "Notifying test listeners of end of test"};
|
||||||
.reportId(reportId)
|
String log = StringUtils.join(contents, SEPARATOR);
|
||||||
.resourceId("none")
|
this.kafkaTemplate.send(topic, log);
|
||||||
.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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user