如何从骆驼的MDC中的慰安队列中读取消息?

时间:2019-07-07 17:25:26

标签: apache-camel mdc solace-mq

我有一个代码,用于读取以队列中的对象形式传递的某些唯一ID。在通过队列使用时,我希望在每个日志中传递该唯一ID。 如何读取该属性?

公共类EcafUnitOfWork扩展了MDCUnitOfWork {

public static final String CAF_NUMBER = "cafNumber";

public EcafUnitOfWork(Exchange exchange) {
    super(exchange);
    Endpoint endPoint = exchange.getFromEndpoint();
    String routeId=exchange.getFromRouteId();
    try {
        if (null != endPoint && (endPoint instanceof DirectEndpoint || endPoint instanceof ServletEndpoint
                || endPoint instanceof JettyHttpEndpoint9)) {
            DigitalSign digitalSign = exchange.getIn().getBody(DigitalSign.class);
            log.debug("received PDF Request {}",digitalSign);
            if (null != pdfDigitalSign) {
                MDC.put(UNIQUE_ID, digitalSign.getUniqueId());
            }
        }
    } catch (Exception e) {
        log.error("Error While Parsing Request {}", e);
    }
}

0 个答案:

没有答案