浏览代码

TracerFormat从RouteBuilder中移除,hos-camel2的一些基础设施只是为了保障服务的独立运行,一般在Broker中已经有,不需要额外上传。

airhead 8 年之前
父节点
当前提交
d0c6ce32f8

+ 30 - 1
hos-camel2/src/main/java/camel/HosCamelApplication.java

@ -1,5 +1,11 @@
package camel;
import camel.log.TracerFormatter;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.processor.interceptor.Tracer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -8,9 +14,32 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 */
@SpringBootApplication
//@EnableEurekaClient
public class HosCamelApplication {
public class HosCamelApplication implements CommandLineRunner {
    @Autowired
    private CamelContext context;
    public static void main(String[] args) {
        SpringApplication.run(HosCamelApplication.class, args);
    }
    @Override
    public void run(String... strings) throws Exception {
        context.setUseMDCLogging(true);
        context.setTracing(true);
        Tracer tracer = new Tracer();
        TracerFormatter 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.getProperties().put(Exchange.LOG_DEBUG_BODY_STREAMS, "true");
        context.getProperties().put(Exchange.BEAN_MULTI_PARAMETER_ARRAY, "true");
    }
}

+ 0 - 20
hos-camel2/src/main/java/camel/api7/route/CxfConsumerTest.java

@ -2,10 +2,8 @@ package camel.api7.route;
import camel.api7.processor.ToWsProcessor;
import camel.gateway.processor.GatewayProcessor;
import camel.log.TracerFormatter;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.processor.interceptor.Tracer;
import org.springframework.stereotype.Component;
@Component
@ -20,24 +18,6 @@ public class CxfConsumerTest extends RouteBuilder {
    // START SNIPPET: example
    public void configure() {
        this.getContext().setUseMDCLogging(true);
        this.getContext().setTracing(true);
        Tracer tracer = new Tracer();
        TracerFormatter formatter = new TracerFormatter();
        formatter.setShowHeaders(true);
        formatter.setShowBody(true);
        formatter.setShowBodyType(true);
        formatter.setShowOutHeaders(true);
        formatter.setShowOutBody(true);
        formatter.setShowOutBodyType(true);
        formatter.setMultiline(true);
        tracer.setFormatter(formatter);
        this.getContext().addInterceptStrategy(tracer);
        this.getContext().getProperties().put(Exchange.LOG_DEBUG_BODY_STREAMS, "true");
        this.getContext().getProperties().put(Exchange.BEAN_MULTI_PARAMETER_ARRAY, "true");
        from(SIMPLE_ENDPOINT_URI)
                .setHeader(Exchange.BEAN_MULTI_PARAMETER_ARRAY, constant(true))
                .process(new ToWsProcessor())

+ 2 - 22
hos-camel2/src/main/java/camel/gateway/route/GatewayRouterBuilder.java

@ -4,10 +4,8 @@ import camel.gateway.processor.ErrorHandle;
import camel.gateway.processor.GatewayProcessor;
import camel.gateway.processor.SignProcessor;
import camel.gateway.processor.WsProcessor;
import camel.log.TracerFormatter;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.processor.interceptor.Tracer;
import org.springframework.stereotype.Component;
/**
@ -22,27 +20,9 @@ public class GatewayRouterBuilder extends RouteBuilder {
            + "?serviceClass=camel.gateway.processor.WsService"
//            + "&dataFormat=CXF_MESSAGE"
            ;
    @Override
    public void configure() throws Exception {
        this.getContext().setUseMDCLogging(true);
        this.getContext().setTracing(true);
        Tracer tracer = new Tracer();
//        DefaultTraceFormatter formatter = new DefaultTraceFormatter();
        TracerFormatter formatter = new TracerFormatter();
        formatter.setShowHeaders(true);
        formatter.setShowBody(true);
        formatter.setShowBodyType(true);
        formatter.setShowOutHeaders(true);
        formatter.setShowOutBody(true);
        formatter.setShowOutBodyType(true);
        tracer.setFormatter(formatter);
        this.getContext().addInterceptStrategy(tracer);
        this.getContext().getProperties().put(Exchange.LOG_DEBUG_BODY_STREAMS, "true");
        this.getContext().getProperties().put(Exchange.BEAN_MULTI_PARAMETER_ARRAY, "true");
        from("jetty:http://0.0.0.0:9998?matchOnUriPrefix=true").routeId("proxy")
                .to("jetty:http://192.168.1.221:10000?bridgeEndpoint=true&throwExceptionOnFailure=false");
@ -68,7 +48,7 @@ public class GatewayRouterBuilder extends RouteBuilder {
                .setHeader(Exchange.BEAN_MULTI_PARAMETER_ARRAY, constant(true))
                .process(new WsProcessor())
                .routingSlip(method(GatewayProcessor.class, "route"))
        .to("bean:wsProcessor?method=responseWs")
                .to("bean:wsProcessor?method=responseWs")
        ;
    }