Class 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:
    Serialized Form
    • Field Detail

      • 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 Detail

      • 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 Detail

      • 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
      • 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()