Package org.axonframework.eventhandling
Class GenericDomainEventMessage<T>
java.lang.Object
org.axonframework.messaging.MessageDecorator<T>
org.axonframework.eventhandling.GenericEventMessage<T>
org.axonframework.eventhandling.GenericDomainEventMessage<T>
- Type Parameters:
T- The type of payload contained in this Message
- All Implemented Interfaces:
Serializable,DomainEventMessage<T>,EventMessage<T>,Message<T>
- Direct Known Subclasses:
GenericTrackedDomainEventMessage
public class GenericDomainEventMessage<T>
extends GenericEventMessage<T>
implements DomainEventMessage<T>
Generic implementation of a
DomainEventMessage.- See Also:
-
Field Summary
Fields inherited from class org.axonframework.eventhandling.GenericEventMessage
clock -
Constructor Summary
ConstructorsConstructorDescriptionGenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, Message<T> delegate, Instant timestamp) Initialize a DomainEventMessage originating from an Aggregate with the givenaggregateIdentifier, with givensequenceNumberandpayload,metaDataandtimestamp.GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, Message<T> delegate, Supplier<Instant> timestamp) Initialize a DomainEventMessage originating from an Aggregate using existing data.GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload) Initialize a DomainEventMessage originating from an Aggregate with the givenaggregateIdentifier, with givensequenceNumberandpayload.GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload, Map<String, ?> metaData) Initialize a DomainEventMessage originating from an Aggregate with the givenaggregateIdentifier, with givensequenceNumberandpayloadandmetaData.GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload, Map<String, ?> metaData, String messageIdentifier, Instant timestamp) Initialize a DomainEventMessage originating from an Aggregate using existing data. -
Method Summary
Modifier and TypeMethodDescriptionandMetaData(Map<String, ?> metaData) Returns a copy of this EventMessage with it MetaData merged with the givenmetaData.protected voiddescribeTo(StringBuilder stringBuilder) Describe the message specific properties to the givenstringBuilder.protected StringDescribe the type of message, used inMessageDecorator.toString().Returns the identifier of the Aggregate that generated this DomainEvent.longReturns the sequence number that allows DomainEvents originating from the same Aggregate to be placed in the order of generation.getType()Returns the type of the Aggregate that generated this DomainEvent.withMetaData(Map<String, ?> metaData) Returns a copy of this EventMessage with the givenmetaData.Methods inherited from class org.axonframework.eventhandling.GenericEventMessage
asEventMessage, getTimestampMethods inherited from class org.axonframework.messaging.MessageDecorator
getDelegate, getIdentifier, getMetaData, getPayload, getPayloadType, serializeMetaData, serializePayload, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.axonframework.eventhandling.EventMessage
getIdentifier, getTimestampMethods inherited from interface org.axonframework.messaging.Message
getMetaData, getPayload, getPayloadType, serializeMetaData, serializePayload
-
Constructor Details
-
GenericDomainEventMessage
public GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload) Initialize a DomainEventMessage originating from an Aggregate with the givenaggregateIdentifier, with givensequenceNumberandpayload. The MetaData of the message is empty.- Parameters:
type- The domain typeaggregateIdentifier- The identifier of the aggregate generating this messagesequenceNumber- The message's sequence numberpayload- The application-specific payload of the message
-
GenericDomainEventMessage
public GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload, Map<String, ?> metaData) Initialize a DomainEventMessage originating from an Aggregate with the givenaggregateIdentifier, with givensequenceNumberandpayloadandmetaData.- Parameters:
type- The domain typeaggregateIdentifier- The identifier of the aggregate generating this messagesequenceNumber- The message's sequence numberpayload- The application-specific payload of the messagemetaData- The MetaData to attach to the message
-
GenericDomainEventMessage
public GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload, Map<String, ?> metaData, String messageIdentifier, Instant timestamp) Initialize a DomainEventMessage originating from an Aggregate using existing data.- Parameters:
type- The domain typeaggregateIdentifier- The identifier of the aggregate generating this messagesequenceNumber- The message's sequence numberpayload- The application-specific payload of the messagemetaData- The MetaData to attach to the messagemessageIdentifier- The message identifiertimestamp- The event's timestamp
-
GenericDomainEventMessage
public GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, Message<T> delegate, Supplier<Instant> timestamp) Initialize a DomainEventMessage originating from an Aggregate using existing data. The timestamp of the event is supplied lazily to prevent unnecessary deserialization of the timestamp.- Parameters:
type- The domain typeaggregateIdentifier- The identifier of the aggregate generating this messagesequenceNumber- The message's sequence numberdelegate- The delegate message providing the payload, metadata and identifier of the eventtimestamp- The event's timestamp supplier
-
GenericDomainEventMessage
public GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, Message<T> delegate, Instant timestamp) Initialize a DomainEventMessage originating from an Aggregate with the givenaggregateIdentifier, with givensequenceNumberandpayload,metaDataandtimestamp.- Parameters:
type- the aggregate typeaggregateIdentifier- the aggregate identifiersequenceNumber- the sequence number of the eventdelegate- The delegate message providing the payload, metadata and identifier of the eventtimestamp- the timestamp of the event
-
-
Method Details
-
getType
Description copied from interface:DomainEventMessageReturns the type of the Aggregate that generated this DomainEvent. By default this is equal to the simple class name of the aggregate root.- Specified by:
getTypein interfaceDomainEventMessage<T>- Returns:
- the type of the Aggregate that generated this DomainEvent
-
getAggregateIdentifier
Description copied from interface:DomainEventMessageReturns 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.- Specified by:
getAggregateIdentifierin interfaceDomainEventMessage<T>- Returns:
- the identifier of the Aggregate that generated this DomainEvent
-
getSequenceNumber
public long getSequenceNumber()Description copied from interface:DomainEventMessageReturns the sequence number that allows DomainEvents originating from the same Aggregate to be placed in the order of generation.- Specified by:
getSequenceNumberin interfaceDomainEventMessage<T>- Returns:
- the sequence number of this Event
-
withMetaData
Description copied from interface:EventMessageReturns a copy of this EventMessage with the givenmetaData. The payload,TimestampandIdentifierremain unchanged.- Specified by:
withMetaDatain interfaceDomainEventMessage<T>- Specified by:
withMetaDatain interfaceEventMessage<T>- Specified by:
withMetaDatain interfaceMessage<T>- Overrides:
withMetaDatain classGenericEventMessage<T>- Parameters:
metaData- The new MetaData for the Message- Returns:
- a copy of this message with the given MetaData
-
andMetaData
Description copied from interface:EventMessageReturns a copy of this EventMessage with it MetaData merged with the givenmetaData. The payload,TimestampandIdentifierremain unchanged.- Specified by:
andMetaDatain interfaceDomainEventMessage<T>- Specified by:
andMetaDatain interfaceEventMessage<T>- Specified by:
andMetaDatain interfaceMessage<T>- Overrides:
andMetaDatain classGenericEventMessage<T>- Parameters:
metaData- The MetaData to merge with- Returns:
- a copy of this message with the given MetaData
-
describeTo
Description copied from class:MessageDecoratorDescribe the message specific properties to the givenstringBuilder. Subclasses should override this method, calling the super method and appending their own properties to the end (or beginning).As convention, String values should be enclosed in single quotes, Objects in curly brackets and numeric values may be appended without enclosing. All properties should be preceded by a comma when appending, or finish with a comma when prefixing values.
- Overrides:
describeToin classGenericEventMessage<T>- Parameters:
stringBuilder- the builder to append data to
-
describeType
Description copied from class:MessageDecoratorDescribe the type of message, used inMessageDecorator.toString().Defaults to the simple class name of the actual instance.
- Overrides:
describeTypein classGenericEventMessage<T>- Returns:
- the type of message
-