public class GenericMessage<T> extends AbstractMessage<T>
Message
that contains the payload and metadata as unserialized values.
If a GenericMessage is created while a UnitOfWork
is active it copies
over the correlation data of the UnitOfWork to the created message.
Constructor and Description |
---|
GenericMessage(String identifier,
T payload,
Map<String,?> metaData)
Constructor to reconstruct a Message using existing data.
|
GenericMessage(T payload)
Constructs a Message for the given
payload using the correlation data of the current Unit of Work, if
present. |
GenericMessage(T payload,
Map<String,?> metaData)
Constructs a Message for the given
payload and meta data . |
Modifier and Type | Method and Description |
---|---|
MetaData |
getMetaData()
Returns the meta data for this event.
|
T |
getPayload()
Returns the payload of this Event.
|
Class<T> |
getPayloadType()
Returns the type of the payload.
|
protected Message<T> |
withMetaData(MetaData metaData)
Returns a new message instance with the same payload and properties as this message but given
metaData . |
andMetaData, getIdentifier, withMetaData
public GenericMessage(T payload)
payload
using the correlation data of the current Unit of Work, if
present.payload
- The payload for the messagepublic GenericMessage(T payload, Map<String,?> metaData)
payload
and meta data
. The given metaData
is
merged with the MetaData from the correlation data of the current unit of work, if present.payload
- The payload for the messagemetaData
- The meta data for the messagepublic GenericMessage(String identifier, T payload, Map<String,?> metaData)
GenericMessage(Object, Map)
instead.identifier
- The identifier of the Messagepayload
- The payload of the messagemetaData
- The meta data of the messagepublic MetaData getMetaData()
Message
public T getPayload()
Message
public Class<T> getPayloadType()
Message
getPayload().getClass()
, but allows implementations to optimize by using
lazy loading or deserialization.protected Message<T> withMetaData(MetaData metaData)
AbstractMessage
metaData
.withMetaData
in class AbstractMessage<T>
metaData
- The metadata in the new messageCopyright © 2010–2017. All rights reserved.