Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Invalid
-
3.5.0
-
None
-
None
-
my project is attached
-
Unknown
Description
my build.gradle is
plugins { id 'org.springframework.boot' version '2.3.5.RELEASE' id 'io.spring.dependency-management' version '1.0.10.RELEASE' id 'java' } group = 'com.bvn13' version = '0.0.1-SNAPSHOT' sourceCompatibility = '11' configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } dependencies { //implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' //implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.apache.camel.springboot:camel-spring-boot-starter:3.5.0' implementation 'org.apache.camel:camel-http:3.5.0' implementation 'org.apache.camel:camel-jetty:3.5.0' implementation 'org.apache.camel:camel-gson:3.5.0' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } } test { useJUnitPlatform() }
my route builder is:
import org.apache.camel.builder.RouteBuilder; import org.apache.camel.model.dataformat.JsonLibrary; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import lombok.extern.slf4j.Slf4j; @Slf4j @Component public class EgaisExpirationDateSearcher extends RouteBuilder { private final String host; private final int port; private final String searchEndpoint; public EgaisExpirationDateSearcher( @Value("${app.listen.host}") String host, @Value("${app.listen.port}") int port) { this.host = host; this.port = port; searchEndpoint = "jetty:http://"+host+":"+port+"/expire"; log.info("Listening at: {}", searchEndpoint); } @Override public void configure() throws Exception { from(searchEndpoint+"?httpMethodRestrict=POST") .log("${body}") // <----------------- .unmarshal().json(JsonLibrary.Gson, SearchRequest.class) .log("${body}") .process((exchange) -> { exchange.getMessage().setBody("HI!"); }) ; } }
my application properties are:
app: listen: host: localhost port: 9091
I have an object as request body:
import lombok.Value; @Value public class SearchRequest { String contraInn; String alcoGoodName; }
I perform POST HTTP request like
curl -X POST -H "Content-Type: application/json" -d '{"contraInn":123,"alcoGoodName":"name"}' http://localhost:9091/expire
now take a look at pointed line in route builder:
.log("${body}") // <-----------------
if I comment this line (disable logging) the log has following lines:
2020-11-10 22:07:52.172 INFO 1344 --- [ main] c.b.b.e.EgaisConnectorApplication : Started EgaisConnectorApplication in 2.003 seconds (JVM running for 2.982)
2020-11-10 22:11:05.575 INFO 1344 --- [tp1753113235-31] route2 : com.bvn13.beerspot.egaisconnector.SearchRequest@2d34001a
but when I uncomment pointed line the body seems become empty right after logging:
2020-11-10 22:12:40.284 INFO 10924 --- [ main] c.b.b.e.EgaisConnectorApplication : Started EgaisConnectorApplication in 1.932 seconds (JVM running for 2.78) 2020-11-10 22:12:46.854 INFO 10924 --- [qtp216919586-31] route2 : {"contraInn":123,"alcoGoodName":"name"} 2020-11-10 22:12:46.857 INFO 10924 --- [qtp216919586-31] route2 : null
First log message is logged as arrived, then emptied , unmarshalled to null and logged out as null.
Is it normal?