The headers for a {@link Message}.
IMPORTANT: This class is immutable. Any mutating operation such as {@code put(..)}, {@code putAll(..)} and others will throw{@link UnsupportedOperationException}.
Subclasses do have access to the raw headers, however, via {@link #getRawHeaders()}.
One way to create message headers is to use the {@link org.springframework.messaging.support.MessageBuilder MessageBuilder}:
MessageBuilder.withPayload("foo").setHeader("key1", "value1").setHeader("key2", "value2");
A second option is to create {@link org.springframework.messaging.support.GenericMessage}passing a payload as {@link Object} and headers as a {@link Map 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 {@link org.springframework.messaging.support.MessageHeaderAccessor}or one of its subclasses to create specific categories of headers.
@author Arjen Poutsma
@author Mark Fisher
@author Gary Russell
@since 4.0
@see org.springframework.messaging.support.MessageBuilder
@see org.springframework.messaging.support.MessageHeaderAccessor