Class AbstractMessage<T>

java.lang.Object
org.axonframework.messaging.AbstractMessage<T>
All Implemented Interfaces:
Serializable, Message<T>
Direct Known Subclasses:
GenericMessage, SerializedMessage

public abstract class AbstractMessage<T> extends Object implements Message<T>
Abstract base class for Messages.
Author:
Rene de Waele
See Also:
  • Constructor Details

    • AbstractMessage

      public AbstractMessage(String identifier)
      Initializes a new message with given identifier.
      Parameters:
      identifier - the message identifier
  • Method Details

    • getIdentifier

      public String getIdentifier()
      Description copied from interface: Message
      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.
      Specified by:
      getIdentifier in interface Message<T>
      Returns:
      the unique identifier of this message
    • withMetaData

      public Message<T> withMetaData(@Nonnull Map<String,?> metaData)
      Description copied from interface: Message
      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.

      Specified by:
      withMetaData in interface Message<T>
      Parameters:
      metaData - The new MetaData for the Message
      Returns:
      a copy of this message with the given MetaData
    • andMetaData

      public Message<T> andMetaData(@Nonnull Map<String,?> metaData)
      Description copied from interface: Message
      Returns a copy of this Message with it MetaData merged with the given metaData. The payload remains unchanged.
      Specified by:
      andMetaData in interface Message<T>
      Parameters:
      metaData - The MetaData to merge with
      Returns:
      a copy of this message with the given MetaData
    • withMetaData

      protected abstract Message<T> withMetaData(MetaData metaData)
      Returns a new message instance with the same payload and properties as this message but given metaData.
      Parameters:
      metaData - The metadata in the new message
      Returns:
      a copy of this instance with given metadata