Passing values between processors in apache camel

kgautron picture kgautron · Apr 26, 2012 · Viewed 36.1k times · Source

In apache camel, which of those is the best way to pass values from an exchange processor to another (and why) :

  • storing it in the exchange headers
  • using the setProperty method while building the route.
  • another way..

Answer

Claus Ibsen picture Claus Ibsen · Apr 27, 2012

One distinction not mentioned by Ben and Petter is that properties are safely stored for the entire duration of the processing of the message in Camel. In contrast, headers are part of the message protocol, and may not be propagated during routing. For example, JMS has limitations what you can store as headers etc.

You may want to read the free chapter 1 of the Camel in Action book as it covers the Camel concepts with Exchange, Message, etc.