Here's an example of what I like to do: Use the REST DSL to expose routes. Each REST endpoint forwards the Java object along with the headers given by the endpoint (corresponding to HTTP headers, path parameters, and query parameters) to a dedicated queue (or topic) for each REST endpoint. Using the JMS component, this all works just fine. However, if I wanted to replace this middleware with something like Kafka, Hazelcast, or even something amusing like IRC or XMPP, I lose all my headers. I don't want to change the message body because that is typically the contents of the POST/PUT body.
On 25 November 2015 at 11:39, Joakim Bjørnstad <joak...@gmail.com> wrote: > Yes, you typically use them for route internal metadata. > > But they are not lost when they enter and return from an endpoint, > unless you or the component creates a fresh new exchange. > > Please also see this SO: > > http://stackoverflow.com/questions/10330998/passing-values-between-processors-in-apache-camel > > > On Wed, Nov 25, 2015 at 4:00 PM, Matt Sicker <boa...@gmail.com> wrote: > > Properties get lost even more often than headers, though. They're only > > copied when the entire Exchange is used instead of the message body or > the > > Message object. I use them for temporary metadata between Processors, > > beans, etc. > > > > On 25 November 2015 at 06:54, Joakim Bjørnstad <joak...@gmail.com> > wrote: > > > >> Hello, > >> > >> If you need metadata or a value on multiple endpoints, or to be used > >> internally in your routes, it is better to put them in the > >> exchangeProperties. Then copy them out to headers, when needed. Since > >> headers are meant to be used at the protocol/component in/out, there > >> is no guarantee they persist or be unchanged when the message returns. > >> Also reduces unwanted metadata leaking out of your routes, for example > >> to JMS, HTTP/SOAP as you mentioned. > >> > >> > >> > >> On Wed, Nov 25, 2015 at 12:52 AM, Matt Sicker <boa...@gmail.com> wrote: > >> > I filter out what headers to send when making REST calls through http4 > >> for > >> > instance, so that's not an issue. When I make internal calls to > networked > >> > services (e.g., Kafka, Hazelcast, or pretty much anything other than > the > >> > message brokering components), I lose all my headers until the > response > >> > message is handled (and only some components save those headers). > >> > > >> > On 24 November 2015 at 16:36, ychawla <premiergenerat...@gmail.com> > >> wrote: > >> > > >> >> That sounds sensible to me. The headers are for message and exchange > >> >> metadata. Just be careful to not send them over the wire when you > call > >> an > >> >> external component. > >> >> > >> >> > >> >> > >> >> -- > >> >> View this message in context: > >> >> > >> > http://camel.465427.n5.nabble.com/Am-I-using-headers-right-tp5774363p5774365.html > >> >> Sent from the Camel - Users mailing list archive at Nabble.com. > >> >> > >> > > >> > > >> > > >> > -- > >> > Matt Sicker <boa...@gmail.com> > >> > >> > >> > >> -- > >> Kind regards > >> Joakim Bjørnstad > >> > > > > > > > > -- > > Matt Sicker <boa...@gmail.com> > > > > -- > Kind regards > Joakim Bjørnstad > -- Matt Sicker <boa...@gmail.com>