org.axonframework.domain
Interface Message<T>

Type Parameters:
T - The type of payload contained in this Message
All Superinterfaces:
Serializable
All Known Subinterfaces:
CommandMessage<T>, DomainEventMessage<T>, EventMessage<T>
All Known Implementing Classes:
GenericCommandMessage, GenericDomainEventMessage, GenericEventMessage, GenericMessage, SerializationAwareDomainEventMessage, SerializationAwareEventMessage, SerializedDomainEventMessage, SerializedEventMessage, SerializedMessage

public interface Message<T>
extends Serializable

Representation of a Message, containing a Payload and MetaData. Typical examples of Messages are Commands and Events.

Instead of implementing Message directly, consider implementing CommandMessage or EventMessage instead.

Since:
2.0
Author:
Allard Buijze
See Also:
CommandMessage, EventMessage

Method Summary
 Message<T> andMetaData(Map<String,?> metaData)
          Returns a copy of this Message with it MetaData merged with the given metaData.
 String getIdentifier()
          Returns the identifier of this message.
 MetaData getMetaData()
          Returns the meta data for this event.
 T getPayload()
          Returns the payload of this Event.
 Class getPayloadType()
          Returns the type of the payload.
 Message<T> withMetaData(Map<String,?> metaData)
          Returns a copy of this Message with the given metaData.
 

Method Detail

getIdentifier

String getIdentifier()
Returns the identifier of this message. Two messages with the same identifiers should be interpreted as different representations of the same conceptual message. In such case, the meta-data may be different for both representations. The payload may be identical.

Returns:
the unique identifier of this message

getMetaData

MetaData getMetaData()
Returns the meta data for this event. This meta data is a collection of key-value pairs, where the key is a String, and the value is a serializable object.

Returns:
the meta data for this event

getPayload

T getPayload()
Returns the payload of this Event. The payload is the application-specific information.

Returns:
the payload of this Event

getPayloadType

Class getPayloadType()
Returns the type of the payload.

Is semantically equal to getPayload().getClass(), but allows implementations to optimize by using lazy loading or deserialization.

Returns:
the type of payload.

withMetaData

Message<T> withMetaData(Map<String,?> metaData)
Returns a copy of this Message with the given metaData. The payload remains unchanged.

While the implementation returned may be different than the implementation of this, implementations must take special care in returning the same type of Message (e.g. EventMessage, DomainEventMessage) to prevent errors further downstream.

Parameters:
metaData - The new MetaData for the Message
Returns:
a copy of this message with the given MetaData

andMetaData

Message<T> andMetaData(Map<String,?> metaData)
Returns a copy of this Message with it MetaData merged with the given metaData. The payload remains unchanged.

Parameters:
metaData - The MetaData to merge with
Returns:
a copy of this message with the given MetaData


Copyright © 2010-2016. All Rights Reserved.