- java.lang.Object
-
- aeonics.entity.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 theQueueto subscribe to aTopicand 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 Messageclone()Returns a new deep copy of this messageNetwork.Connectionconnection()Returns the linked connection, or null if there is none.Messageconnection(Network.Connection value)Sets the linked connectionDatacontent()Returns the content of the message.Messagecontent(Data value)Sets the content of the messageDataexport()Exports this message to a data representation.java.lang.Stringkey()Returns the message binding key.Messagekey(java.lang.String value)Sets the message binding keyDatametadata()Returns the metadata of the message in the form of key/valuestatic Messageof(Data data)Returns a message instance from its exported data representationjava.lang.StringtoString()java.lang.Stringuser()Returns the id of the user related to this message.Messageuser(java.lang.String value)Sets the id of the user related to this message
-
-
-
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
Userinstance should be fetched from theRegistryif 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:
clonein classjava.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:
exportin interfaceExportable- Returns:
- a data representation of this message
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-