com.feingto.cloud.dto.message.TraceMessageDTO Maven / Gradle / Ivy
package com.feingto.cloud.dto.message;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.feingto.cloud.core.json.JSON;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* API 跟踪消息体
*
* @author longfei
*/
@Slf4j
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TraceMessageDTO implements Serializable {
private static final long serialVersionUID = -9086222595728796504L;
private String apiId;
private String url;
private Long duration;// 耗时(毫秒)
private String message;
@Builder.Default
private boolean success = true;// 返回状态成功/失败
@Builder.Default
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdDate = new Date();
@Builder.Default
private Map tags = new HashMap<>();
public Message toMessage() {
String message = JSON.build().obj2json(this);
log.info("Tracing message \"{}\".", message);
return MessageBuilder.withPayload(message).build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy