Messageconsists of a Payload, which is an application-specific object that represents the actual functional message, and Meta Data, which is a key-value pair describing the context of the message.
Message's sub-interfaces represent a specific type of message, and defines additional information that describes that Message. Unlike Meta Data, this additional information defines information required for correct processing of that type of message.
MetaDatain Axon is immutable. Mutating methods will create and return a new instance, instead of modifying an existing one.
MetaDatainstance with the indicated key-value pair
withMetaDatareplaces any Meta Data in the message with the given Map.
java.util.Collections.singletonMap()is used to define a single entry.
andMetaDataadds the entries from the given Map to the Message's metadata. Existing entries with equal keys are overwritten.
Note - about
Map<String, Object>, meaning that instead of passing a
singletonMap(or any other type of Map), you can also use
MetaData.with(key, value). As
MetaDatais immutable, all mutating operations of
Mapwill throw an
EventMessage(an interface extending
Message) also provides a timestamp, representing the time at which the event was generated. The
QueryMessagecarries, besides Payload and Meta Data, a description of the type of response that the requesting component expects.