public class MutableMessage<T>
extends java.lang.Object
implements org.springframework.messaging.Message<T>, java.io.Serializable
Message
with a generic payload. Unlike
GenericMessage
, this message (or its headers) can be modified after creation.
Great care must be taken, when mutating messages, that some other element/thread is not
concurrently using the message. Also note that any in-memory stores (such as
SimpleMessageStore
) may have a reference to the message and changes will be
reflected there too.
IMPORTANT: Mutable messages may share state (such as message headers); such messages should never be exposed to other components or undesirable side-effects may result.
It is generally recommended that messages transferred between components should always be immutable unless great care is taken with their use.
Modifier | Constructor and Description |
---|---|
|
MutableMessage(T payload) |
|
MutableMessage(T payload,
java.util.Map<java.lang.String,java.lang.Object> headers) |
protected |
MutableMessage(T payload,
MutableMessageHeaders headers) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
MutableMessageHeaders |
getHeaders() |
T |
getPayload() |
int |
hashCode() |
java.lang.String |
toString() |
public MutableMessage(T payload)
public MutableMessage(T payload, java.util.Map<java.lang.String,java.lang.Object> headers)
protected MutableMessage(T payload, MutableMessageHeaders headers)
public MutableMessageHeaders getHeaders()
getHeaders
in interface org.springframework.messaging.Message<T>
public T getPayload()
getPayload
in interface org.springframework.messaging.Message<T>
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object