Class GenericDeadlineMessage<T>

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

public class GenericDeadlineMessage<T> extends GenericEventMessage<T> implements DeadlineMessage<T>
Generic implementation of the DeadlineMessage.
Since:
3.3
Author:
Milan Savic, Steven van Beelen
See Also:
  • Constructor Details

    • GenericDeadlineMessage

      public GenericDeadlineMessage(@Nonnull String deadlineName)
      Instantiate a GenericDeadlineMessage with the given deadlineName, a null payload and en empty MetaData.
      Parameters:
      deadlineName - A String denoting the deadline's name
    • GenericDeadlineMessage

      public GenericDeadlineMessage(@Nonnull String deadlineName, @Nullable T payload)
      Instantiate a GenericDeadlineMessage with the given deadlineName, a payload of type T and en empty MetaData.
      Parameters:
      deadlineName - A String denoting the deadline's name
      payload - The payload of type T for the DeadlineMessage
    • GenericDeadlineMessage

      public GenericDeadlineMessage(@Nonnull String deadlineName, @Nullable T payload, @Nonnull Map<String,?> metaData)
      Instantiate a GenericDeadlineMessage with the given deadlineName, a payload of type T and the given metaData.
      Parameters:
      deadlineName - A String denoting the deadline's name
      payload - The payload of the Message
      metaData - The MetaData of the Message
    • GenericDeadlineMessage

      public GenericDeadlineMessage(@Nonnull String deadlineName, @Nonnull String identifier, @Nullable T payload, Map<String,?> metaData, Instant timestamp)
      Constructor to reconstructs a DeadlineMessage using existing data.
      Parameters:
      deadlineName - A String denoting the deadline's name
      identifier - The identifier of type String for the Message
      payload - The payload of type T for the Message
      metaData - The MetaData of the Message
      timestamp - An Instant timestamp of the Message creation
    • GenericDeadlineMessage

      public GenericDeadlineMessage(@Nonnull String deadlineName, @Nonnull Message<T> delegate, @Nonnull Supplier<Instant> timestampSupplier)
      Constructor to reconstruct a DeadlineMessage using existing data. The timestamp of the event is supplied lazily to prevent unnecessary deserialization of the timestamp.
      Parameters:
      deadlineName - A String denoting the deadline's name
      delegate - The Message containing the payload, identifier and MetaData
      timestampSupplier - Supplier for the timestamp of the Message creation
  • Method Details

    • asDeadlineMessage

      @Deprecated public static <T> DeadlineMessage<T> asDeadlineMessage(@Nonnull String deadlineName, Object messageOrPayload)
      Deprecated.
      Use asDeadlineMessage(String, Object, Instant) instead, as it sets the timestamp of the deadline, rather than the current time
      Returns the given deadlineName and messageOrPayload as a DeadlineMessage. If the messageOrPayload parameter is of type Message, a new DeadlineMessage will be created using the payload and meta data of the given deadline. Otherwise, the given messageOrPayload is wrapped into a GenericDeadlineMessage as its payload.
      Type Parameters:
      T - The generic type of the expected payload of the resulting object
      Parameters:
      deadlineName - A String denoting the deadline's name
      messageOrPayload - A Message or payload to wrap as a DeadlineMessage
      Returns:
      a DeadlineMessage using the deadlineName as its deadline name and containing the given messageOrPayload as the payload
    • asDeadlineMessage

      public static <T> DeadlineMessage<T> asDeadlineMessage(@Nonnull String deadlineName, @Nullable Object messageOrPayload, @Nonnull Instant expiryTime)
      Returns the given deadlineName and messageOrPayload as a DeadlineMessage which expires at the given expiryTime. If the messageOrPayload parameter is of type Message, a new DeadlineMessage instance will be created using the payload and meta data of the given message. Otherwise, the given messageOrPayload is wrapped into a GenericDeadlineMessage as its payload.
      Type Parameters:
      T - The generic type of the expected payload of the resulting object
      Parameters:
      deadlineName - A String denoting the deadline's name
      messageOrPayload - A Message or payload to wrap as a DeadlineMessage
      expiryTime - The timestamp at which the deadline expires
      Returns:
      a DeadlineMessage using the deadlineName as its deadline name and containing the given messageOrPayload as the payload
    • getDeadlineName

      public String getDeadlineName()
      Description copied from interface: DeadlineMessage
      Retrieve a String representing the name of this DeadlineMessage.
      Specified by:
      getDeadlineName in interface DeadlineMessage<T>
      Returns:
      a String representing the name of this DeadlineMessage
    • withMetaData

      public GenericDeadlineMessage<T> withMetaData(@Nonnull Map<String,?> metaData)
      Description copied from interface: EventMessage
      Returns a copy of this EventMessage with the given metaData. The payload, Timestamp and Identifier remain unchanged.
      Specified by:
      withMetaData in interface DeadlineMessage<T>
      Specified by:
      withMetaData in interface EventMessage<T>
      Specified by:
      withMetaData in interface Message<T>
      Overrides:
      withMetaData in class GenericEventMessage<T>
      Parameters:
      metaData - The new MetaData for the Message
      Returns:
      a copy of this message with the given MetaData
    • andMetaData

      public GenericDeadlineMessage<T> andMetaData(@Nonnull Map<String,?> additionalMetaData)
      Description copied from interface: EventMessage
      Returns a copy of this EventMessage with it MetaData merged with the given metaData. The payload, Timestamp and Identifier remain unchanged.
      Specified by:
      andMetaData in interface DeadlineMessage<T>
      Specified by:
      andMetaData in interface EventMessage<T>
      Specified by:
      andMetaData in interface Message<T>
      Overrides:
      andMetaData in class GenericEventMessage<T>
      Parameters:
      additionalMetaData - The MetaData to merge with
      Returns:
      a copy of this message with the given MetaData
    • 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