Package org.axonframework.eventhandling
Class EventUtils
java.lang.Object
org.axonframework.eventhandling.EventUtils
Utility class for dealing with events.
- Since:
- 3.0
- Author:
- Rene de Waele
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> DomainEventMessage<T> asDomainEventMessage(EventMessage<T> eventMessage) Deprecated.since this method is not used for external use.static <T> TrackedEventMessage<T> asTrackedEventMessage(EventMessage<T> eventMessage, TrackingToken trackingToken) static Stream<TrackedEventMessage<?>> upcastAndDeserializeTrackedEvents(Stream<? extends TrackedEventData<?>> eventEntryStream, Serializer serializer, EventUpcaster upcasterChain) Upcasts and deserializes the giveneventEntryStreamusing the givenserializerandupcasterChain.
-
Method Details
-
asTrackedEventMessage
public static <T> TrackedEventMessage<T> asTrackedEventMessage(EventMessage<T> eventMessage, TrackingToken trackingToken) Convert anEventMessageto aTrackedEventMessageusing the giventrackingToken. If the event is aDomainEventMessagethe message will be converted to aGenericTrackedDomainEventMessage, otherwise aGenericTrackedEventMessageis returned.- Type Parameters:
T- the payload type of the event- Parameters:
eventMessage- the message to converttrackingToken- the tracking token to use for the resulting message- Returns:
- the message converted to a tracked event message
-
asDomainEventMessage
@Deprecated public static <T> DomainEventMessage<T> asDomainEventMessage(EventMessage<T> eventMessage) Deprecated.since this method is not used for external use. This method is intended to deduce whether a givenEventMessageis aDomainEventMessageand if not, push it into being one by adjusting the fields. However, this is only intended to simplify the storage of events. This does not make a regularEventMessageaDomainEventMessageby any means. The only way to have a trueDomainEventMessageis by publishing events from within an Aggregate, by using theAggregateLifecycleoperations.Convert a plainEventMessageto aDomainEventMessage. If the message already is aDomainEventMessageit will be returned as is. Otherwise a newGenericDomainEventMessageis made withnulltype,aggregateIdentifierequal tomessageIdentifierand sequence number of 0L.- Type Parameters:
T- The type of payload in the message- Parameters:
eventMessage- the input event message- Returns:
- the message converted to a domain event message
-
upcastAndDeserializeTrackedEvents
public static Stream<TrackedEventMessage<?>> upcastAndDeserializeTrackedEvents(Stream<? extends TrackedEventData<?>> eventEntryStream, Serializer serializer, EventUpcaster upcasterChain) Upcasts and deserializes the giveneventEntryStreamusing the givenserializerandupcasterChain.The list of events returned contains lazy deserializing events for optimization purposes. Events represented with unknown classes are ignored if
skipUnknownTypesistrue- Parameters:
eventEntryStream- the stream of entries containing the data of the serialized eventserializer- the serializer to deserialize the event withupcasterChain- the chain containing the upcasters to upcast the events with- Returns:
- a stream of lazy deserializing events
-