java.lang.Object
dk.cloudcreate.essentials.shared.functional.tuple.Pair<Object,MessageMetaData>
dk.cloudcreate.essentials.components.foundation.messaging.queue.Message
dk.cloudcreate.essentials.components.foundation.messaging.queue.OrderedMessage
All Implemented Interfaces:
dk.cloudcreate.essentials.shared.functional.tuple.Tuple<dk.cloudcreate.essentials.shared.functional.tuple.Pair<Object,MessageMetaData>>, Serializable

public class OrderedMessage extends Message
Represents a message that will be delivered in order.
This of course requires that message are queued in order and that the consumer is single threaded.
All messages sharing the same key, will be delivered according to their order
An example of a message key is the id of the entity the message relates to
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final String
    All messages sharing the same key, will be delivered according to their order
    An example of a message key is the id of the entity the message relates to
    final long
    Represent the order of the message relative to the key.
    All messages sharing the same key, will be delivered according to their order

    Fields inherited from class dk.cloudcreate.essentials.shared.functional.tuple.Pair

    _1, _2
  • Constructor Summary

    Constructors
    Constructor
    Description
    OrderedMessage(Object payload, String key, long order)
     
    OrderedMessage(Object payload, String key, long order, MessageMetaData metaData)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    All messages sharing the same key, will be delivered according to their getOrder()
    An example of a message key is the id of the entity the message relates to
    long
    Represent the order of a message relative to the getKey().
    All messages sharing the same key, will be delivered according to their getOrder()
    of(Object payload, String key, long order)
    Create a new Message and an empty MessageMetaData
    of(Object payload, String key, long order, MessageMetaData metaData)
    Create a new Message
     

    Methods inherited from class dk.cloudcreate.essentials.components.foundation.messaging.queue.Message

    getMetaData, getPayload, of, of

    Methods inherited from class dk.cloudcreate.essentials.shared.functional.tuple.Pair

    _1, _2, arity, equals, hashCode, map, map, map1, map2, of, swap, toEntry, toList

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • key

      public final String key
      All messages sharing the same key, will be delivered according to their order
      An example of a message key is the id of the entity the message relates to
    • order

      public final long order
      Represent the order of the message relative to the key.
      All messages sharing the same key, will be delivered according to their order
  • Constructor Details

    • OrderedMessage

      public OrderedMessage(Object payload, String key, long order)
      Parameters:
      payload - the message payload
      key - the message key. All messages sharing the same key, will be delivered according to their getOrder()
      order - the order of the message relative to the getKey().
    • OrderedMessage

      public OrderedMessage(Object payload, String key, long order, MessageMetaData metaData)
      Parameters:
      payload - the message payload
      key - the message key. All messages sharing the same key, will be delivered according to their getOrder()
      order - the order of the message relative to the getKey().
      metaData - the MessageMetaData associated with the message
  • Method Details

    • of

      public static OrderedMessage of(Object payload, String key, long order)
      Create a new Message and an empty MessageMetaData
      Parameters:
      payload - the message payload
      key - the message key. All messages sharing the same key, will be delivered according to their getOrder()
      order - the order of the message relative to the getKey().
      Returns:
      the new Message
    • of

      public static OrderedMessage of(Object payload, String key, long order, MessageMetaData metaData)
      Create a new Message
      Parameters:
      payload - the message payload
      key - the message key. All messages sharing the same key, will be delivered according to their getOrder()
      order - the order of the message relative to the getKey().
      metaData - the MessageMetaData associated with the message
      Returns:
      the new Message
    • getKey

      public String getKey()
      All messages sharing the same key, will be delivered according to their getOrder()
      An example of a message key is the id of the entity the message relates to
      Returns:
      The message key
    • getOrder

      public long getOrder()
      Represent the order of a message relative to the getKey().
      All messages sharing the same key, will be delivered according to their getOrder()
      Returns:
      the order of a message relative to the getKey()
    • toString

      public String toString()
      Overrides:
      toString in class Message