public class GenericMessage<T> extends Object implements Message<T>, Serializable
Message
with a generic payload.
Once created, a GenericMessage is immutable.MessageBuilder
,
Serialized FormConstructor and Description |
---|
GenericMessage(T payload)
Create a new message with the given payload.
|
GenericMessage(T payload,
Map<String,Object> headers)
Create a new message with the given payload and headers.
|
GenericMessage(T payload,
MessageHeaders headers)
A constructor with the
MessageHeaders instance to use. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
MessageHeaders |
getHeaders()
Return message headers for the message (never
null but may be empty). |
T |
getPayload()
Return the message payload.
|
int |
hashCode() |
String |
toString() |
public GenericMessage(T payload)
payload
- the message payload (never null
)public GenericMessage(T payload, Map<String,Object> headers)
payload
- the message payload (never null
)headers
- message headers to use for initializationpublic GenericMessage(T payload, MessageHeaders headers)
MessageHeaders
instance to use.
Note: the given MessageHeaders
instance is used
directly in the new message, i.e. it is not copied.
payload
- the message payload (never null
)headers
- message headerspublic T getPayload()
Message
getPayload
in interface Message<T>
public MessageHeaders getHeaders()
Message
null
but may be empty).getHeaders
in interface Message<T>