Interface DomainEventMessage<T>

Type Parameters:
T - The type of payload contained in this Message
All Superinterfaces:
EventMessage<T>, Message<T>, Serializable
All Known Implementing Classes:
GenericDomainEventMessage, GenericTrackedDomainEventMessage

public interface DomainEventMessage<T> extends EventMessage<T>
Represents a Message that wraps a DomainEvent and an Event representing an important change in the Domain. In contrast to a regular EventMessage, a DomainEventMessages contains the identifier of the Aggregate that reported it. The DomainEventMessage's sequence number allows Messages to be placed in their order of generation.
Since:
2.0
Author:
Allard Buijze
  • Method Details

    • getSequenceNumber

      long getSequenceNumber()
      Returns the sequence number that allows DomainEvents originating from the same Aggregate to be placed in the order of generation.
      Returns:
      the sequence number of this Event
    • getAggregateIdentifier

      String getAggregateIdentifier()
      Returns the identifier of the Aggregate that generated this DomainEvent. Note that the value returned does not necessarily have to be the same instance that was provided at creation time. It is possible that (due to serialization, for example) the value returned here has a different structure.
      Returns:
      the identifier of the Aggregate that generated this DomainEvent
    • getType

      String getType()
      Returns the type of the Aggregate that generated this DomainEvent. By default this is equal to the simple class name of the aggregate root.
      Returns:
      the type of the Aggregate that generated this DomainEvent
    • withMetaData

      DomainEventMessage<T> withMetaData(@Nonnull Map<String,?> metaData)
      Returns a copy of this DomainEventMessage with the given metaData. The payload, Timestamp and EventIdentifier, as well as the Aggregate Identifier and Sequence Number remain unchanged.
      Specified by:
      withMetaData in interface EventMessage<T>
      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

      DomainEventMessage<T> andMetaData(@Nonnull Map<String,?> metaData)
      Returns a copy of this DomainEventMessage with its MetaData merged with the given metaData. The payload, Timestamp and EventIdentifier, as well as the Aggregate Identifier and Sequence Number remain unchanged.
      Specified by:
      andMetaData in interface EventMessage<T>
      Specified by:
      andMetaData in interface Message<T>
      Parameters:
      metaData - The MetaData to merge with
      Returns:
      a copy of this message with the given MetaData