Bläddra i källkod

MDC增加消息长度,可以用于计算吞吐量

Airhead 8 år sedan
förälder
incheckning
88e5103a6e

+ 5 - 3
hos-broker/src/main/java/com/yihu/hos/models/BusinessLog.java

@ -23,8 +23,10 @@ public class BusinessLog {
    private String breadcrumbId;
    private String camelContextId;
    private String body;
    private String bodyLength;
    private Integer bodyLength;
    private String fireTimeSource;
    //@Indexed(name = "fireTime_1", expireAfterSeconds = 30)
    @Indexed
    private Date fireTime;  //后期建议转成TTL
@ -100,11 +102,11 @@ public class BusinessLog {
        this.fireTime = fireTime;
    }
    public String getBodyLength() {
    public Integer getBodyLength() {
        return bodyLength;
    }
    public void setBodyLength(String bodyLength) {
    public void setBodyLength(Integer bodyLength) {
        this.bodyLength = bodyLength;
    }

+ 1 - 0
hos-broker/src/main/java/com/yihu/hos/services/BusinessLogService.java

@ -26,6 +26,7 @@ public class BusinessLogService {
            BusinessLog businessLog = objectMapper.readValue(msg, BusinessLog.class);
            String fireTimeSource = businessLog.getFireTimeSource();
            businessLog.setFireTime(DateUtil.toTimestamp(fireTimeSource));
            businessLog.setBodyLength(businessLog.getBody().length());
            mongoOperations.save(businessLog);
        } catch (IOException e) {
            e.printStackTrace();