Class GenericEventMessage
- All Implemented Interfaces:
Message,EventMessage
- Direct Known Subclasses:
TerminalEventMessage
EventMessage interface.- Since:
- 2.0.0
- Author:
- Allard Buijze, Rene de Waele, Steven van Beelen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic ClockDeprecated.#3083 - Configure application wide ClockFields inherited from interface org.axonframework.messaging.core.Message
RESOURCE_KEY -
Constructor Summary
ConstructorsModifierConstructorDescriptionGenericEventMessage(String identifier, MessageType type, Object payload, Map<String, String> metadata, Instant timestamp) Constructs aGenericEventMessagefor the givenidentifier,type,payload,metadata, andtimestamp.protectedGenericEventMessage(Message delegate, Instant timestamp) Constructs aGenericEventMessagewith givendelegateandtimestamp.GenericEventMessage(Message delegate, Supplier<Instant> timestampSupplier) Constructs aGenericEventMessagefor the givendelegateandtimestampSupplier, intended to reconstruct anotherEventMessage.GenericEventMessage(MessageType type, Object payload) Constructs aGenericEventMessagefor the giventypeandpayload.GenericEventMessage(MessageType type, Object payload, Map<String, String> metadata) Constructs aGenericEventMessagefor the giventype,payloadandmetadata. -
Method Summary
Modifier and TypeMethodDescriptionandMetadata(Map<String, String> metadata) protected voiddescribeTo(StringBuilder stringBuilder) Describe the message specific properties to the givenstringBuilder.protected StringDescribe the type of message, used inMessageDecorator.toString().Returns the timestamp of thisevent.withConvertedPayload(Type type, Converter converter) Returns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.withMetadata(Map<String, String> metadata) Returns a copy of thisMessage(implementation) with the givenmetadata.Methods inherited from class org.axonframework.messaging.core.MessageDecorator
delegate, identifier, metadata, payload, payloadAs, payloadType, toString, typeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.axonframework.messaging.eventhandling.EventMessage
identifier, withConvertedPayload, withConvertedPayload
-
Field Details
-
clock
Deprecated.#3083 - Configure application wide ClockClockinstance used to set the time on new events. To fix the time while testing set this value to a constant value.
-
-
Constructor Details
-
GenericEventMessage
Constructs aGenericEventMessagefor the giventypeandpayload.The
Metadatadefaults to an empty instance.- Parameters:
type- Thetypefor thisEventMessage.payload- The payload for thisEventMessage.
-
GenericEventMessage
public GenericEventMessage(@Nonnull MessageType type, @Nullable Object payload, @Nonnull Map<String, String> metadata) Constructs aGenericEventMessagefor the giventype,payloadandmetadata.- Parameters:
type- Thetypefor thisEventMessage.payload- The payload for thisEventMessage.metadata- The metadata for thisEventMessage.
-
GenericEventMessage
public GenericEventMessage(@Nonnull String identifier, @Nonnull MessageType type, @Nullable Object payload, @Nonnull Map<String, String> metadata, @Nonnull Instant timestamp) Constructs aGenericEventMessagefor the givenidentifier,type,payload,metadata, andtimestamp.- Parameters:
identifier- The identifier of thisEventMessage.type- Thetypefor thisEventMessage.payload- The payload for thisEventMessage.metadata- The metadata for thisEventMessage.timestamp- Thetimestampof thisEventMessage'screation.
-
GenericEventMessage
Constructs aGenericEventMessagefor the givendelegateandtimestampSupplier, intended to reconstruct anotherEventMessage.The timestamp of the event is supplied lazily through the given
timestampSupplierto prevent unnecessary deserialization of the timestamp.Unlike the other constructors, this constructor will not attempt to retrieve any correlation data from the Unit of Work.
- Parameters:
delegate- TheMessagecontainingpayload,type,identifierandmetadatafor theEventMessageto reconstruct.timestampSupplier-Supplierfor thetimestampof theEventMessage'screation.
-
GenericEventMessage
Constructs aGenericEventMessagewith givendelegateandtimestamp.The
delegatewill be used supply thepayload,type,metadataandidentifierof the resultingGenericEventMessage.Unlike the other constructors, this constructor will not attempt to retrieve any correlation data from the Unit of Work.
- Parameters:
delegate- TheMessagecontainingpayload,type,identifierandmetadatafor theEventMessageto reconstruct.timestamp- Thetimestampof thisGenericEventMessage'screation.
-
-
Method Details
-
timestamp
Description copied from interface:EventMessageReturns the timestamp of thisevent.The timestamp is set to the date and time the event was reported.
- Specified by:
timestampin interfaceEventMessage- Returns:
- The timestamp of this
event.
-
withMetadata
Description copied from interface:MessageReturns a copy of thisMessage(implementation) with the givenmetadata.All other fields, like for example the
Message.payload(), remain unchanged.While the implementation returned may be different from the implementation of
this, implementations must take special care in returning the same type ofMessageto prevent errors further downstream.- Specified by:
withMetadatain interfaceEventMessage- Specified by:
withMetadatain interfaceMessage- Parameters:
metadata- The new metadata for theMessage.- Returns:
- A copy of
this Message (implementation)with the givenmetadata.
-
andMetadata
Description copied from interface:MessageReturns a copy of thisMessage(implementation) with itsmetadatamerged with the givenmetadata.All other fields, like for example the
Message.payload(), remain unchanged.- Specified by:
andMetadatain interfaceEventMessage- Specified by:
andMetadatain interfaceMessage- Parameters:
metadata- The metadata to merge with.- Returns:
- A copy of
this Message (implementation)with the givenmetadata.
-
withConvertedPayload
Description copied from interface:MessageReturns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter. This newMessageis effectively a copy ofthis Messagewith a renewed payload andMessage.payloadType().Will return the
thisinstance if thepayload typeisassignable fromthe converted result.- Specified by:
withConvertedPayloadin interfaceEventMessage- Specified by:
withConvertedPayloadin interfaceMessage- Overrides:
withConvertedPayloadin classMessageDecorator- Parameters:
type- The type to convert theMessage.payload()to.converter- The converter to convert theMessage.payload()with.- Returns:
- A new
Messageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.
-
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 classMessageDecorator- 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 classMessageDecorator- Returns:
- The type of the message.
-