Class MessageHeaders

All Implemented Interfaces:
Serializable, Map<String,Object>

public class MessageHeaders extends Object implements Map<String,Object>, Serializable
The headers for a Message.

IMPORTANT: This class is immutable. Any mutating operation such as put(..), putAll(..) and others will throw UnsupportedOperationException.

Subclasses do have access to the raw headers, however, via getRawHeaders().

One way to create message headers is to use the MessageBuilder:

 MessageBuilder.withPayload("foo").setHeader("key1", "value1").setHeader("key2", "value2");
A second option is to create GenericMessage passing a payload as Object and headers as a java.util.Map:
 Map headers = new HashMap();
 headers.put("key1", "value1");
 headers.put("key2", "value2");
 new GenericMessage("foo", headers);
A third option is to use MessageHeaderAccessor or one of its subclasses to create specific categories of headers.
Arjen Poutsma, Mark Fisher, Gary Russell, Juergen Hoeller
See Also: