Search code examples
apache-camel

Camel Body: body1 -> body2 -> body1?


I have a message body. Then, I change it. Then, I want to reset it back to the original message body:

from("{{route:from}}") // step 1
.setBody("hello world") // step 2
.setBody(/*set body back to value produced by step 1*/);

How do I reset the body back to the value produced by step 1?


Solution

  • You can copy the body to an exchange property before the first time you change the body, and then restore it afterwards. You can also look at the claim check EIP that has push/pop actions for such behaviour.