refactor(性能测试): 手动停止测试发送通知修改
This commit is contained in:
parent
198bb154c4
commit
c91cf585fa
|
@ -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<String, Object> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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