Class EventUtils

java.lang.Object
org.axonframework.eventhandling.EventUtils

public abstract class EventUtils extends Object
Utility class for dealing with events.
Since:
3.0
Author:
Rene de Waele
  • Method Details

    • asTrackedEventMessage

      public static <T> TrackedEventMessage<T> asTrackedEventMessage(EventMessage<T> eventMessage, TrackingToken trackingToken)
      Convert an EventMessage to a TrackedEventMessage using the given trackingToken. If the event is a DomainEventMessage the message will be converted to a GenericTrackedDomainEventMessage, otherwise a GenericTrackedEventMessage is returned.
      Type Parameters:
      T - the payload type of the event
      Parameters:
      eventMessage - the message to convert
      trackingToken - 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 given EventMessage is a DomainEventMessage and 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 regular EventMessage a DomainEventMessage by any means. The only way to have a true DomainEventMessage is by publishing events from within an Aggregate, by using the AggregateLifecycle operations.
      Convert a plain EventMessage to a DomainEventMessage. If the message already is a DomainEventMessage it will be returned as is. Otherwise a new GenericDomainEventMessage is made with null type, aggregateIdentifier equal to messageIdentifier and 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 given eventEntryStream using the given serializer and upcasterChain.

      The list of events returned contains lazy deserializing events for optimization purposes. Events represented with unknown classes are ignored if skipUnknownTypes is true

      Parameters:
      eventEntryStream - the stream of entries containing the data of the serialized event
      serializer - the serializer to deserialize the event with
      upcasterChain - the chain containing the upcasters to upcast the events with
      Returns:
      a stream of lazy deserializing events