java - Camel message body null after log -


i've problem whit camel. i've configurations:

<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>      <!-- camel-http4 component provides http based endpoints calling          external http resources (as client call external servers using http) -->     <dependency>         <groupid>org.apache.camel</groupid>         <artifactid>camel-http4</artifactid>         <version>${env.camel.version}</version>     </dependency>      <!-- stream: component provides access system.in, system.out          , system.err streams allowing streaming of file , 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 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 xls view -->     <dependency>         <groupid>org.apache.poi</groupid>         <artifactid>poi</artifactid>         <version>${apache.poi.microsoft.version}</version>     </dependency> 

i've camel context attribute set:

<camelcontext xmlns="http://camel.apache.org/schema/spring"     trace="#{config.cameltrace}" usemdclogging="true" streamcache="true"> 

this route definitions:

<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> 

if remove log body message populated correctly, if activate have null message body

this application logs:

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

p.s: sorry bad english :(

i'm solved it.

add camelcontext streamcache=true (default disabled after camel 2.0):

<camelcontext xmlns="http://camel.apache.org/schema/spring"     trace="#{config.cameltrace}" usemdclogging="true" streamcache="true"> 

and add body after read it:

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"); 

regards umberto


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -