Hi Johannes,
I don't know if there's any best practice. But I think the headers are a
good place for storing meta data containing to the message.
pro class:
- a class is explicit, so you know what properties are available (anyway
- you can store such an object inside the message headers, so there's no
need to modify the payload)
pro header:
- it is in line with the camel concept, no extra steps as copy (yes
headers should keep intact while routing)
- it's flexible, you can easily add headers without changing your code
(deleting is a bit different ;)
- the body is 'clean'
- you can use all Camel tools to get or set values (java DSL, spring
DSL, Annotaitions, etc...)
Perhaps there're some more :)
Best regards - Claus
On 18.05.2011 15:10, Klug, Johannes wrote:
Is there any best practice as to what to use message headers for? I
asked this a few weeks ago on this list but only got one response.
In our project, we were discussing whether to put meta-data like name,
description, timestamp, message source, and others into header fields.
The one reply I got last time suggested to create a custom class for our
purpose and put the meta-data into fields, along with the message body.
What are the downsides of using Camel message headers?
Are they not guaranteed to be kept intact while en route?
Cheers,
Johannes
-----Original Message-----
From: Claus Ibsen [mailto:[email protected]]
Sent: 18 May 2011 12:15
To: [email protected]
Subject: Re: camel message headers
Yep you can store anything you like. The type is java.lang.Object.
If you use the DSL you can do
.setHeader("myHeader", constant(new MyObject())). ...
On Wed, May 18, 2011 at 12:10 PM, tnk<[email protected]> wrote:
Hi,
what values can be stored in message headers (using camel 2.6)?
Is it restricted only to String values (like setHeader("MY_HEADER",
"string
value"))?
Can I store any Java object (serializable) in message header
(setHeader("MY_HEADER", new MyNewObject()) )
--
View this message in context:
http://camel.465427.n5.nabble.com/camel-message-headers-
tp4406101p4406101.html
Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: [email protected]
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Think green - keep it on the screen.
This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an intended
recipient then please promptly delete this e-mail and any attachment and all
copies and inform the sender. Thank you.