Class GenericTrackedEventMessage<T>

Type Parameters:
T - The type of payload contained in this Message
All Implemented Interfaces:
Serializable, EventMessage<T>, TrackedEventMessage<T>, Message<T>

public class GenericTrackedEventMessage<T> extends GenericEventMessage<T> implements TrackedEventMessage<T>
Generic implementation of a TrackedEventMessage.
See Also:
  • Constructor Details

    • GenericTrackedEventMessage

      public GenericTrackedEventMessage(TrackingToken trackingToken, EventMessage<T> delegate)
      Creates a GenericTrackedEventMessage with given trackingToken and delegate event message.
      Parameters:
      trackingToken - tracking token of the event
      delegate - delegate message containing payload, metadata, identifier and timestamp
    • GenericTrackedEventMessage

      public GenericTrackedEventMessage(TrackingToken trackingToken, Message<T> delegate, Supplier<Instant> timestamp)
      Creates a GenericTrackedEventMessage with given trackingToken and delegate event message. The timestamp of the event is supplied lazily to prevent unnecessary deserialization of the timestamp.
      Parameters:
      trackingToken - tracking token of the event
      delegate - delegate message containing payload, metadata, identifier and timestamp
      timestamp - supplier of the message's timestamp
    • GenericTrackedEventMessage

      protected GenericTrackedEventMessage(TrackingToken trackingToken, Message<T> delegate, Instant timestamp)
      Initializes a GenericTrackedEventMessage with given message as delegate and given timestamp. The given message will be used supply the payload, metadata and identifier of the resulting event message.
      Parameters:
      trackingToken - the tracking token of the resulting message
      delegate - the message that will be used used as delegate
      timestamp - the timestamp of the resulting event message
  • Method Details

    • trackingToken

      public TrackingToken trackingToken()
      Description copied from interface: TrackedEventMessage
      Returns the TrackingToken of the event message.
      Specified by:
      trackingToken in interface TrackedEventMessage<T>
      Returns:
      the tracking token of the event
    • describeTo

      protected void describeTo(StringBuilder stringBuilder)
      Description copied from class: MessageDecorator
      Describe the message specific properties to the given stringBuilder. 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:
      describeTo in class GenericEventMessage<T>
      Parameters:
      stringBuilder - the builder to append data to
    • withTrackingToken

      public GenericTrackedEventMessage<T> withTrackingToken(TrackingToken trackingToken)
      Description copied from interface: TrackedEventMessage
      Creates a copy of this message with the given trackingToken to replace the one in this message.

      This method is useful in case streams are modified (combined, split), and the tokens of the combined stream are different than the originating stream.

      Specified by:
      withTrackingToken in interface TrackedEventMessage<T>
      Parameters:
      trackingToken - The tracking token to replace
      Returns:
      a new instance of a message with a different tracking token
    • describeType

      protected String describeType()
      Description copied from class: MessageDecorator
      Describe the type of message, used in MessageDecorator.toString().

      Defaults to the simple class name of the actual instance.

      Overrides:
      describeType in class GenericEventMessage<T>
      Returns:
      the type of message