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 obj) |
MessageHeaders |
getHeaders()
Return message headers for the message (never
null ). |
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 MessageHeaders getHeaders()
Message
null
).getHeaders
in interface Message<T>
public T getPayload()
Message
getPayload
in interface Message<T>