Message.Important Note
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 org.springframework.messaging.support.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 org.springframework.messaging.support.MessageHeaderAccessor
or one of its subclasses to create specific categories of headers.
org.springframework.messaging.support.MessageBuilder , org.springframework.messaging.support.MessageHeaderAccessor
| Modifier and Type | Field and Description |
|---|---|
| public static final String | CONTENT_TYPE
The key for the message content type. |
| private static final IdGenerator | |
| public static final String | ERROR_CHANNEL
The key for the message error channel. |
| private final Map | |
| public static final String | ID
The key for the Message ID. This is an automatically generated UUID and should never be explicitly set in the header map except in the case of Message deserialization where the serialized Message's generated UUID is being restored. |
| public static final UUID | ID_VALUE_NONE
UUID for none. |
| private static volatile IdGenerator | |
| private static final Log | |
| public static final String | REPLY_CHANNEL
The key for the message reply channel. |
| private static final long | |
| public static final String | TIMESTAMP
The key for the message timestamp. |
| Access | Constructor and Description |
|---|---|
| public | MessageHeaders(Map<String, Object>
a map with headers to add headers)Construct a |
| protected | |
| private | MessageHeaders(MessageHeaders
the MessageHeaders to copy original, Set<String> the keys of the entries to ignore keysToIgnore)Copy constructor which allows for ignoring certain entries. |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Implements java. UnsupportedOperationException.
|
| public boolean | containsKey(Object
key whose presence in this map is to be tested key)Implements java. true if this map contains a mapping for the specified
key.
|
| public boolean | containsValue(Object
value whose presence in this map is to be tested value)Implements java. true if this map maps one or more keys to the
specified value.
|
| public Set | entrySet()
Implements java. Set view of the mappings contained in this map.
|
| public boolean | equals(Object
object to be compared for equality with this map other)Overrides java. Implements java. |
| public <T> T | |
| public Object | get(Object
the key whose associated value is to be returned key)Implements java. null if this map contains no mapping for the key.
|
| public Object | |
| public UUID | |
| protected static IdGenerator | |
| protected Map | |
| public Object | |
| public Long | |
| public int | hashCode()
Overrides java. Implements java. |
| public boolean | |
| public Set | |
| public Object | put(String
key with which the specified value is to be associated key, Object value to be associated with the specified key value)Implements java. UnsupportedOperationException.
|
| public void | putAll(Map<? extends String, ? extends Object>
mappings to be stored in this map map)Implements java. UnsupportedOperationException.
|
| private void | |
| public Object | remove(Object
key whose mapping is to be removed from the map key)Implements java. UnsupportedOperationException.
|
| public int | |
| public String | |
| public Collection | values()
Implements java. Collection view of the values contained in this map.
|
| private void |
| CONTENT_TYPE | back to summary |
|---|---|
| public static final String CONTENT_TYPE The key for the message content type. | |
| defaultIdGenerator | back to summary |
|---|---|
| private static final IdGenerator defaultIdGenerator | |
| ERROR_CHANNEL | back to summary |
|---|---|
| public static final String ERROR_CHANNEL The key for the message error channel. | |
| headers | back to summary |
|---|---|
private final Map<String, Object> headers
| |
| ID | back to summary |
|---|---|
| public static final String ID The key for the Message ID. This is an automatically generated UUID and should never be explicitly set in the header map except in the case of Message deserialization where the serialized Message's generated UUID is being restored. | |
| ID_VALUE_NONE | back to summary |
|---|---|
| public static final UUID ID_VALUE_NONE UUID for none. | |
| idGenerator | back to summary |
|---|---|
| private static volatile IdGenerator idGenerator
| |
| logger | back to summary |
|---|---|
| private static final Log logger | |
| REPLY_CHANNEL | back to summary |
|---|---|
| public static final String REPLY_CHANNEL The key for the message reply channel. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| TIMESTAMP | back to summary |
|---|---|
| public static final String TIMESTAMP The key for the message timestamp. | |
| MessageHeaders | back to summary |
|---|---|
| public MessageHeaders(Map<String, Object> headers) Construct a | |
| MessageHeaders | back to summary |
|---|---|
| protected MessageHeaders(Map<String, Object> headers, UUID id, Long timestamp) Constructor providing control over the ID and TIMESTAMP header values. | |
| MessageHeaders | back to summary |
|---|---|
| private MessageHeaders(MessageHeaders original, Set<String> keysToIgnore) Copy constructor which allows for ignoring certain entries. Used for serialization without non-serializable entries.
| |
| clear | back to summary |
|---|---|
| public void clear() Implements java. Since MessageHeaders are immutable, the call to this method
will result in
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(Object key) Implements java. Doc from java. Returns | |
| containsValue | back to summary |
|---|---|
| public boolean containsValue(Object value) Implements java. Doc from java. Returns | |
| entrySet | back to summary |
|---|---|
| public Set Implements java. Doc from java. Returns a | |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Implements java. Doc from java. Compares the specified object with this map for equality. Returns
| |
| get | back to summary |
|---|---|
public <T> T get(Object key, Class<T> type)
| |
| get | back to summary |
|---|---|
| public Object get(Object key) Implements java. Doc from java. Returns the value to which the specified key is mapped,
or More formally, if this map contains a mapping from a key
If this map permits null values, then a return value of
| |
| getErrorChannel | back to summary |
|---|---|
public Object getErrorChannel()
| |
| getId | back to summary |
|---|---|
public UUID getId()
| |
| getIdGenerator | back to summary |
|---|---|
| protected static IdGenerator getIdGenerator() | |
| getRawHeaders | back to summary |
|---|---|
| protected Map | |
| getReplyChannel | back to summary |
|---|---|
public Object getReplyChannel()
| |
| getTimestamp | back to summary |
|---|---|
public Long getTimestamp()
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this map. The hash code of a map is
defined to be the sum of the hash codes of each entry in the map's
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements java. Doc from java. Returns
| |
| keySet | back to summary |
|---|---|
| public Set Implements java. Doc from java. Returns a | |
| put | back to summary |
|---|---|
| public Object put(String key, Object value) Implements java. Since MessageHeaders are immutable, the call to this method
will result in
| |
| putAll | back to summary |
|---|---|
| public void putAll(Map<? extends String, ? extends Object> map) Implements java. Since MessageHeaders are immutable, the call to this method
will result in
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException | |
| remove | back to summary |
|---|---|
| public Object remove(Object key) Implements java. Since MessageHeaders are immutable, the call to this method
will result in
| |
| size | back to summary |
|---|---|
| public int size() Implements java. Doc from java. Returns the number of key-value mappings in this map. If the
map contains more than
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| values | back to summary |
|---|---|
| public Collection Implements java. Doc from java. Returns a
| |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream out) throws IOException | |