Module aeonics.core

Class Message

  • All Implemented Interfaces:
    Exportable

    public class Message
    extends java.lang.Object
    implements Exportable
    A Message is the common data container that convey information across the system.

    Each message has several components:

    • key(): the binding key that is used by the Queue to subscribe to a Topic and target this message.
    • user(): the id of the related user. That is, if the message is authenticated for a particular user.
    • content(): the actual content of the message, it can be any structured or flat value. By default it is a data map.
    • connection(): the optional linked connection. This is usually set in a request/response flow.
    • metadata(): any metadata related to this message in the form of key/value.
    • Constructor Summary

      Constructors 
      Constructor Description
      Message​(java.lang.String key)
      Creates a new message with the provided binding key
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Message clone()
      Returns a new deep copy of this message
      Network.Connection connection()
      Returns the linked connection, or null if there is none.
      Message connection​(Network.Connection value)
      Sets the linked connection
      Data content()
      Returns the content of the message.
      Message content​(Data value)
      Sets the content of the message
      Data export()
      Exports this message to a data representation.
      java.lang.String key()
      Returns the message binding key.
      Message key​(java.lang.String value)
      Sets the message binding key
      Data metadata()
      Returns the metadata of the message in the form of key/value
      static Message of​(Data data)
      Returns a message instance from its exported data representation
      java.lang.String toString()  
      java.lang.String user()
      Returns the id of the user related to this message.
      Message user​(java.lang.String value)
      Sets the id of the user related to this message
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Message

        public Message​(java.lang.String key)
        Creates a new message with the provided binding key
        Parameters:
        key - the message binding key
    • Method Detail

      • key

        public java.lang.String key()
        Returns the message binding key. The key is never null, but it can be empty.
        Returns:
        the message binding key
      • key

        public Message key​(java.lang.String value)
        Sets the message binding key
        Parameters:
        value - the message binding key
        Returns:
        this
      • user

        public java.lang.String user()
        Returns the id of the user related to this message.

        The id may be null if this message does not relate to any user.

        The User instance should be fetched from the Registry if needed.

        Returns:
        the id of the user related to this message
      • user

        public Message user​(java.lang.String value)
        Sets the id of the user related to this message
        Parameters:
        value - the id of the user related to this message
        Returns:
        this
      • content

        public Data content()
        Returns the content of the message. It may be any type of data, binary, key-value, list,... The data is never null but it can be empty.
        Returns:
        the content of the message
      • content

        public Message content​(Data value)
        Sets the content of the message
        Parameters:
        value - the content of the message
        Returns:
        this
      • metadata

        public Data metadata()
        Returns the metadata of the message in the form of key/value
        Returns:
        the metadata of the message
      • connection

        public Network.Connection connection()
        Returns the linked connection, or null if there is none. The linked connection is typically used to send a response to this message request.
        Returns:
        the linked connection, or null if there is none
      • connection

        public Message connection​(Network.Connection value)
        Sets the linked connection
        Parameters:
        value - the linked connection
        Returns:
        this
      • of

        public static Message of​(Data data)
        Returns a message instance from its exported data representation
        Parameters:
        data - the exported message representation
        Returns:
        a message instance
      • clone

        public Message clone()
        Returns a new deep copy of this message
        Overrides:
        clone in class java.lang.Object
        Returns:
        a new deep copy of this message
      • export

        public Data export()
        Exports this message to a data representation.

        Since the active connection cannot be represented as data, it will be omited.

        Specified by:
        export in interface Exportable
        Returns:
        a data representation of this message
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object