com.lx.boot.mq.MqInfo Maven / Gradle / Ivy
package com.lx.boot.mq;
import com.lx.boot.OS;
import com.lx.util.LX;
import lombok.Data;
import lombok.experimental.Accessors;
import org.slf4j.MDC;
import java.io.Serializable;
/**
* @author ylx
*/
@Data
@Accessors(chain = true)
public class MqInfo implements Serializable {
private MqInfo(){}
public MqInfo(String className, String methodName) {
this("任务"+LX.md5(className+methodName).substring(0,10),0,null, OS.getApplicationName(),className,methodName);
}
public MqInfo(String nameOfFunction, String serviceName, String className, String methodName) {
this(nameOfFunction,0,null,serviceName,className,methodName);
}
/** 有多个方法需要调用*/
public MqInfo(String nameOfFunction, long delay,long [] retryList, String serviceName, String className, String methodName) {
this.nameOfFunction = nameOfFunction;
this.delay = delay;
this.serviceName = serviceName;
this.className = className;
this.methodName = methodName;
this.requestId = MDC.get("requestId");
this.retryList = retryList;
if (this.retryList == null){
this.retryList = new long[0];
}
if (LX.isEmpty(this.requestId)){
this.requestId = LX.uuid32(10);
OS.setLogTraceId( this.requestId);
}
this.firmId = OS.getFirmId();
}
public static final long serialVersionUID = 5000994421832722661L;
/** 功能名称*/
private String nameOfFunction;
/** log日志ID*/
private String requestId;
/** 公司ID*/
private String firmId;
/** 信息*/
private Object msg;
/** 延时时间 (秒)*/
private long delay;
/** 方法所在服务*/
private String serviceName;
/** 方法所在类*/
private String className;
/** 方法名称*/
private String methodName;
/** 已成功方法*/
private Boolean[] methodSuccessed;
/** 延时时间(秒 重试)*/
private int retryCount;
/** 编写人邮箱*/
private String email;
/** 重试列表默认通知频率),但不保证通知最终一定能成功。*/
private long [] retryList;
/** 重试次数增加*/
public boolean addCount(){
return this.retryList.length > this.retryCount++;
}
/** 获取实际延迟时间*/
public long getActualDelay(){
return this.retryCount==0? this.delay: this.retryList[this.retryCount-1];
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy