|
@ -1,11 +1,15 @@
|
|
|
package com.yihu.hos.broker.services.camel;
|
|
|
|
|
|
import com.yihu.hos.broker.common.log.TracerFormatter;
|
|
|
import com.yihu.hos.broker.services.BrokerServerService;
|
|
|
import com.yihu.hos.broker.util.lang.DynamicClassLoader;
|
|
|
import com.yihu.hos.core.log.Logger;
|
|
|
import com.yihu.hos.core.log.LoggerFactory;
|
|
|
import org.apache.camel.CamelContext;
|
|
|
import org.apache.camel.Exchange;
|
|
|
import org.apache.camel.builder.RouteBuilder;
|
|
|
import org.apache.camel.processor.interceptor.DefaultTraceFormatter;
|
|
|
import org.apache.camel.processor.interceptor.Tracer;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
@ -35,9 +39,26 @@ public class CamelStartBoot {
|
|
|
logger.info("Apache Camel Context 启动...");
|
|
|
|
|
|
try {
|
|
|
context.setStreamCaching(true); //确保outBody可以消费多次。参考链接:http://camel.apache.org/why-is-my-message-body-empty.html
|
|
|
context.setUseMDCLogging(true);
|
|
|
|
|
|
Tracer tracer = new Tracer();
|
|
|
tracer.setTraceOutExchanges(true);
|
|
|
|
|
|
DefaultTraceFormatter formatter = new TracerFormatter();
|
|
|
formatter.setShowHeaders(true);
|
|
|
formatter.setShowBody(true);
|
|
|
formatter.setShowBodyType(true);
|
|
|
formatter.setShowOutHeaders(true);
|
|
|
formatter.setShowOutBody(true);
|
|
|
formatter.setShowOutBodyType(true);
|
|
|
tracer.setFormatter(formatter);
|
|
|
|
|
|
context.addInterceptStrategy(tracer);
|
|
|
context.setTracing(true);
|
|
|
|
|
|
context.getGlobalOptions().put(Exchange.LOG_DEBUG_BODY_STREAMS, "true");
|
|
|
|
|
|
context.start();
|
|
|
logger.info("Apache Camel Context 启动完成...");
|
|
|
|