rohan
rohan

Reputation: 176

Apache:Camel Request body gets lost after using log component

Whenever I use .log() in my routes the next route receives an empty body. On adding .streamCaching() in the beginning this is resolved, but is this the way I will always have to use. Also will streamCaching have any other effect on the other components? To call the route I am using ProducerTemplates.asyncSendBody()

Upvotes: 0

Views: 1019

Answers (1)

Miloš Milivojević
Miloš Milivojević

Reputation: 5369

From Camel's official documentation:

While stream types (like StreamSource, InputStream and Reader) are commonly used in messaging for performance reasons, they also have an important drawback: they can only be read once. In order to be able to work with message content multiple times, the stream needs to be cached.

So, your issue lies with the fact that the call to .log() will actually read the stream and if it is not cached then subsequent reads will result in no data being return.

Upvotes: 1

Related Questions