Apache Camel - Exchange body is null after upgrading spring boot version

时间:2017-08-04 12:17:46

标签: java spring spring-boot apache-camel integration

We are using apache camel servlet in our spring boot application.

We are registering camel servlet as below:

 @Bean
public ServletRegistrationBean servletRegistrationBean() {
    String camelServletUrlMapping = "/camel/*";
    ServletRegistrationBean registration = new ServletRegistrationBean(new CamelHttpTransportServlet(), camelServletUrlMapping);
    registration.setName(CAMEL_SERVLET_NAME);
    return registration;
}

We have several camel routes bound to servlet . A sample one is as below:

    from("servlet:///{{someendpointpathfromconfig}}?bridgeEndpoint=true&traceEnabled=true")//
        .streamCaching()//
        ...

During route processing we used to convert request body (which is of type org.apache.camel.converter.stream.InputStreamCache) to String by exchange.getIn().getBody(String.class) method.

This is working fine when we use Spring Boot v1.3.3.RELEASE, Spring v4.2.5.RELEASE, Camel 2.17.0.

We have to upgrade to Spring Boot v1.5.6.RELEASE, Spring v4.3.10.RELEASE for several reasons.

After upgrade this approach is not working..

Request body has empty buffer therefore I can not get the body as String...

The interesting thing is that request body is perceived as a header!.. Assuming that request body is "postcontentbody", I noticed that it is mapped as header...

Below is a part of exchange.getIn().getHeaders() representation:

postcontentbody=, user-agent=CORE, x-clientip=127.0.0.1}

I could not find any reason why parsing has changed. The client is the same.. Only boot version has changed.

Using latest Camel 2.19.x version did not change anything either.

Any help is appreciated.

Regards

EDIT

I noticed that problematic client is sending Content-Type=application/x-www-form-urlencoded .

This problem does NOT occur when I send post body from Fiddler and do not set any content-type...

0 个答案:

没有答案