2017-07-28 114 views
0

我有一個問題惠特駱駝。 我這樣的配置:駱駝郵件正文日誌後空

<properties> 
    <env.camel.version>2.19.1</env.camel.version> 
    <env.spring.version>4.3.10.RELEASE</env.spring.version> 
    <spring-security.version>4.2.3.RELEASE</spring-security.version> 
    <org.jvnet.jaxb2_commons.version>0.6.2</org.jvnet.jaxb2_commons.version> 
    <org.codehaus.jackson.version>2.8.9</org.codehaus.jackson.version> 
    <jaxb-api.version>2.2.11</jaxb-api.version> 
    <jaxb.impl.version>${jaxb-api.version}</jaxb.impl.version> 
    <ch.qos.logback.version>1.2.3</ch.qos.logback.version> 
    <org.slf4j.version>1.7.25</org.slf4j.version> 
    <jdk.version>1.7</jdk.version> 
    <itext.pdf.version>4.2.2</itext.pdf.version> 
    <apache.poi.microsoft.version>3.16</apache.poi.microsoft.version> 
    <junit.version>3.8.1</junit.version> 
    <maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version> 
    <restlet-version>2.3.10</restlet-version> 
    <openjpa-all.version>2.4.2</openjpa-all.version> 
    <javax.servlet.jstl.version>1.2</javax.servlet.jstl.version> 
</properties> 

<dependencies> 
    <!-- Dipendenze per Camel start --> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-mail</artifactId> 
     <version>${env.camel.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-core</artifactId> 
     <version>${env.camel.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-spring</artifactId> 
     <version>${env.camel.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-cxf</artifactId> 
     <version>${env.camel.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-jms</artifactId> 
     <version>${env.camel.version}</version> 
    </dependency> 

    <!-- The camel-http4 component provides HTTP based endpoints for calling 
     external HTTP resources (as a client to call external servers using HTTP) --> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-http4</artifactId> 
     <version>${env.camel.version}</version> 
    </dependency> 

    <!-- The stream: component provides access to the System.in, System.out 
     and System.err streams as well as allowing streaming of file and URL. --> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-stream</artifactId> 
     <version>${env.camel.version}</version> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-restlet</artifactId> 
     <version>${env.camel.version}</version> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.activemq</groupId> 
     <artifactId>activemq-camel</artifactId> 
     <version>5.15.0</version> 
     <exclusions> 
      <exclusion> 
       <groupId>org.mortbay.jetty</groupId> 
       <artifactId>jsp-2.1</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>org.mortbay.jetty</groupId> 
       <artifactId>jsp-api-2.1</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-freemarker</artifactId> 
     <version>${env.camel.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-jackson</artifactId> 
     <version>${env.camel.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-jaxb</artifactId> 
     <version>${env.camel.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-servlet</artifactId> 
     <version>${env.camel.version}</version> 
    </dependency> 

    <!-- Dipendenze Camel End --> 

    <!-- Spring dependencies Start --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>${env.spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context-support</artifactId> 
     <version>${env.spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-web</artifactId> 
     <version>${spring-security.version}</version> 
     <exclusions> 
      <exclusion> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring-web</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-config</artifactId> 
     <version>${spring-security.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-expression</artifactId> 
     <version>${env.spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aop</artifactId> 
     <version>${env.spring.version}</version> 
    </dependency> 
    <!-- spring web --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>${env.spring.version}</version> 
    </dependency> 
    <!-- spring web --> 
    <!-- spring webmvc --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>${env.spring.version}</version> 
    </dependency> 
    <!-- spring webmvc --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-beans</artifactId> 
     <version>${env.spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-tx</artifactId> 
     <version>${env.spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-orm</artifactId> 
     <version>${env.spring.version}</version> 
    </dependency> 

    <!-- RESTLET --> 
    <dependency> 
     <groupId>org.restlet.jee</groupId> 
     <artifactId>org.restlet.ext.spring</artifactId> 
     <version>${restlet-version}</version> 
     <exclusions> 
      <exclusion> 
       <artifactId>commons-logging</artifactId> 
       <groupId>commons-logging</groupId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

    <!-- Spring dependencies End --> 


    <!-- JPA/DB --> 
    <dependency> 
     <groupId>org.apache.openjpa</groupId> 
     <artifactId>openjpa-all</artifactId> 
     <version>${openjpa-all.version}</version> 
    </dependency> 
    <!-- Dipendenze per JUnit test start --> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>${junit.version}</version> 
     <scope>test</scope> 
    </dependency> 
    <!-- Dipendenze per JUnit test end --> 


    <!-- dipendenza logback per il logging --> 

    <dependency> 
     <groupId>ch.qos.logback</groupId> 
     <artifactId>logback-core</artifactId> 
     <version>${ch.qos.logback.version}</version> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic --> 
    <dependency> 
     <groupId>ch.qos.logback</groupId> 
     <artifactId>logback-classic</artifactId> 
     <version>${ch.qos.logback.version}</version> 
     <!-- <scope>test</scope> --> 
    </dependency> 

    <!-- SLF4J --> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>${org.slf4j.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>jcl-over-slf4j</artifactId> 
     <version>${org.slf4j.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>jul-to-slf4j</artifactId> 
     <version>${org.slf4j.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>log4j-over-slf4j</artifactId> 
     <version>${org.slf4j.version}</version> 
    </dependency> 
    <!-- dipendenza logback per il logging --> 

    <!-- https://mvnrepository.com/artifact/javax.servlet/jstl --> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>jstl</artifactId> 
     <version>${javax.servlet.jstl.version}</version> 
    </dependency> 

    <!-- Jackson --> 
    <dependency> 
     <groupId>com.fasterxml.jackson.core</groupId> 
     <artifactId>jackson-annotations</artifactId> 
     <version>${org.codehaus.jackson.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>com.fasterxml.jackson.core</groupId> 
     <artifactId>jackson-databind</artifactId> 
     <version>${org.codehaus.jackson.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>com.fasterxml.jackson.core</groupId> 
     <artifactId>jackson-core</artifactId> 
     <version>${org.codehaus.jackson.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>com.fasterxml.jackson.jaxrs</groupId> 
     <artifactId>jackson-jaxrs-json-provider</artifactId> 
     <version>${org.codehaus.jackson.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>com.fasterxml.jackson.module</groupId> 
     <artifactId>jackson-module-jaxb-annotations</artifactId> 
     <version>${org.codehaus.jackson.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>com.fasterxml.jackson.dataformat</groupId> 
     <artifactId>jackson-dataformat-xml</artifactId> 
     <version>${org.codehaus.jackson.version}</version> 
    </dependency> 


    <!-- dipendenze JAXB start --> 
    <dependency> 
     <groupId>javax.xml.bind</groupId> 
     <artifactId>jaxb-api</artifactId> 
     <version>${jaxb-api.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.sun.xml.bind</groupId> 
     <artifactId>jaxb-impl</artifactId> 
     <version>${jaxb.impl.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.jvnet.jaxb2_commons</groupId> 
     <artifactId>jaxb2-basics-runtime</artifactId> 
     <version>${org.jvnet.jaxb2_commons.version}</version> 
    </dependency> 
    <!-- dipendenze JAXB end --> 

    <!-- Needed for PDF View --> 
    <!-- https://mvnrepository.com/artifact/com.lowagie/itext --> 
    <dependency> 
     <groupId>com.lowagie</groupId> 
     <artifactId>itext</artifactId> 
     <version>${itext.pdf.version}</version> 
     <type>pom</type> 
    </dependency> 


    <!-- Needed for XLS View --> 
    <dependency> 
     <groupId>org.apache.poi</groupId> 
     <artifactId>poi</artifactId> 
     <version>${apache.poi.microsoft.version}</version> 
    </dependency> 

我已經這個駱駝上下文屬性設置:

<camelContext xmlns="http://camel.apache.org/schema/spring" 
    trace="#{config.camelTrace}" useMDCLogging="true" streamCache="true"> 

這是我的路由定義:

<route> 
     <from uri="direct:contactTheMovieDb" /> 
     <to 
      uri="http4://api.themoviedb.org/3/movie/550?api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&amp;bridgeEndpoint=true" /> 

     <log message="contactTheMovieDb -> ${body}" loggingLevel="DEBUG" 
      logName="it.umberto" /> 

     <!-- <setProperty propertyName="messageAsString"> --> 
     <!-- <simple>${body}</simple> --> 
     <!-- </setProperty> --> 

     <!-- <process ref="readBodyExchange" /> --> 

     <unmarshal> 
      <json library="Jackson" unmarshalTypeName="it.umberto.Bean.MappingBean.Movie" /> 
     </unmarshal> 

     <process ref="printMovie" /> 


     <!-- <log message="contactTheMovieDb INDENTATO -> ${body}" --> 
     <!-- loggingLevel="DEBUG" logName="it.umberto" /> --> 
    </route> 

    <route> 
     <from uri="restlet:/getMovie" /> 
     <setHeader headerName="CamelHttpMethod"> 
      <constant>GET</constant> 
     </setHeader> 
     <to uri="direct:contactTheMovieDb" /> 
     <!-- <to uri="stream:out" /> --> 
     <log message="getMovie --> ${body}" loggingLevel="DEBUG" logName="it.umberto" /> 
    </route> 

如果我刪除日誌正文填寫正確,但如果激活它,我有null郵件正文

這是我的應用程序日誌:

https://gist.github.com/JafferWilson/7035ec8bf5b8d6aad81e205d3969ebeb

P.S: 對不起我的英語不好:(

+0

太差捐贈日誌和使問題變得模糊不清 –

回答

0

我解決它。

添加到camelContext streamCache = true(默認值後,駱駝2.0禁用):

<camelContext xmlns="http://camel.apache.org/schema/spring" 
    trace="#{config.camelTrace}" useMDCLogging="true" streamCache="true"> 

,並補充身體跟着讀:

LOG.info("................Processor ReadBodyExchange ...........START"); 
    String body = exchange.getIn().getBody(String.class); 
    LOG.info(" ExchangeMessage="+body); 
    exchange.getIn().setBody(body); 
    LOG.info("................Processor ReadBodyExchange ...........END"); 

問候 翁