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(Class<T> declaredPayloadType,
T payload,
Map<String,?> metaData)
Constructs a Message for the given
payload and meta data . |
GenericMessage(String identifier,
Class<T> declaredPayloadType,
T payload,
Map<String,?> metaData)
Constructor to reconstruct a Message using existing data.
|
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.
In case the payload == null
, Void
will be used as the payloadType
.payload
- The payload for the message as a generic T
metaData
- The meta data Map
for the messagepublic GenericMessage(Class<T> declaredPayloadType, 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.declaredPayloadType
- The declared type of message payloadpayload
- 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 messageNullPointerException
- when the given payload
is null
.public GenericMessage(String identifier, Class<T> declaredPayloadType, T payload, Map<String,?> metaData)
GenericMessage(Object, Map)
insteadidentifier
- The identifier of the MessagedeclaredPayloadType
- The declared type of message payloadpayload
- The payload for the messagemetaData
- The meta data for 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–2018. All rights reserved.