Interface EventMessage
- All Superinterfaces:
Message
- All Known Implementing Classes:
GenericEventMessage,TerminalEventMessage
Message wrapping an event, which is represented by its payload.
An event is a representation of an occurrence of an event (i.e. anything that happened any might be of importance to any other component) in the application. It contains the data relevant for components that need to act based on that event.
- Since:
- 2.0.0
- Author:
- Allard Buijze
- See Also:
-
Field Summary
Fields inherited from interface org.axonframework.messaging.core.Message
RESOURCE_KEY -
Method Summary
Modifier and TypeMethodDescriptionandMetadata(Map<String, String> metadata) Returns the identifier of thisevent.Returns the timestamp of thisevent.default EventMessagewithConvertedPayload(Class<?> type, Converter converter) Returns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.withConvertedPayload(Type type, Converter converter) Returns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.default EventMessagewithConvertedPayload(TypeReference<?> 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.
-
Method Details
-
identifier
Returns the identifier of thisevent.The identifier is used to define the uniqueness of an event. Two events may contain similar (or equal)
payloadsandtimestamp, if the event identifiers are different, they both represent a different occurrence of an Event.If two messages have the same identifier, they both represent the same unique occurrence of an event, even though the resulting view may be different. You may not assume two messages are equal (i.e. interchangeable) if their identifier is equal.
For example, an
AddressChangeEventmay occur twice for the same event, because someone moved back to the previous address. In that case, the event payload is equal for bothEventMessageinstances, but the event identifier is different for both.- Specified by:
identifierin interfaceMessage- Returns:
- The identifier of this
event.
-
timestamp
Returns the timestamp of thisevent.The timestamp is set to the date and time the event was reported.
- 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 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 interfaceMessage- Parameters:
metadata- The metadata to merge with.- Returns:
- A copy of
this Message (implementation)with the givenmetadata.
-
withConvertedPayload
@Nonnull default EventMessage withConvertedPayload(@Nonnull Class<?> type, @Nonnull Converter converter) 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 interfaceMessage- 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.
-
withConvertedPayload
@Nonnull default EventMessage withConvertedPayload(@Nonnull TypeReference<?> type, @Nonnull Converter converter) 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 interfaceMessage- 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.
-
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 interfaceMessage- 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.
-