I have 2 identical calls:
String msg1 = exchange.getIn().getBody(String.class);
String msg2 = exchange.getIn().getBody(String.class);
In msg1 I get the correct expected value , but msg2 is an empty string. I'm not setting the Out message , so the exchange In message should be still intact. Please explain why this is happening.
Camel routes:
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="route1">
<from uri="timer://myTimer?period=2000" />
<setBody>
<simple>Hello World ${header.firedTime}</simple>
</setBody>
<process ref="messageProcessor" />
<to uri="http://localhost:8090"/>
</route>
<route id="route2">
<from uri="jetty://http://localhost:8090" />
<process ref="messageProcessor" />
</route>
</camelContext>
The processor contains only the 2 statements from above.
The processing in route1 is correct , but in route2 I get the described behaviour : first call - valid string , second call - empty string. So I think maybe it has something to do with HttpMessage conversion.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…