MigratoryDataMessage
Represent a message.
Public Classes
Name | |
---|---|
enum | MessageType The message type received from MigratoryData server. |
enum | QoS The quality of service (QoS) levels for MigratoryData messaging. |
enum | CompressionAlgorithm The available compression algorithms for message payloads. |
Public Functions
Name | |
---|---|
MigratoryDataMessage(String subject, byte[] content, String closure, QoS qos, boolean retained, String replySubject, boolean compression, CompressionAlgorithm compressionAlgorithm) Create a MigratoryDataMessage object. |
|
String | getSubject() Get the subject of the message. |
byte[] | getContent() Get the content of the message. |
String | getClosure() Get the closure of the message. |
boolean | isRetained() Indicate whether or not the message should be/was retained by the server. |
String | getReplySubject() Get the subject to be used to reply to this message. |
QoS | getQos() Get the QoS level of the message. |
MessageType | getMessageType() Get the MessageType of the message. |
CompressionAlgorithm | getCompressionAlgorithm() const Returns the compression algorithm currently set for the message. |
boolean | isCompressed() Indicate whether or not the message should be/was compressed. |
String | toString() Return a string representation of the message. |
Public Functions Documentation
function MigratoryDataMessage
inline MigratoryDataMessage(
String subject,
byte[] content,
String closure,
QoS qos,
boolean retained,
String replySubject,
boolean compression,
CompressionAlgorithm compressionAlgorithm
)
Create a MigratoryDataMessage object.
Parameters:
- subject The subject of the message
- content The content of the message
- closure The closure of the message; the default is
""
(OPTIONAL) - qos the QoS level of the message; the default is QoS.GUARANTEED (OPTIONAL)
- retained Indicate whether or not the message should be/was retained by the server; the default is
true
(OPTIONAL) - replySubject The reply subject of the message; the default is
""
(OPTIONAL) - compression Indicates whether the message should be or was compressed; the default is
true
(OPTIONAL) - compressionAlgorithm The CompressionAlgorithm set for the message; the default is NONE (OPTIONAL)
If a reply subject is attached to a message, the message acts as a request message. The clients which receive a request message will be able to reply by sending back one or more messages having as subject the reply subject.
Note: If the reply subject is not already subscribed, it will be subscribed by the library implicitly, and it can be reused for request/reply interactions (and even for receiving multiple replies to one request). When it is not needed anymore, it should be unsubscribed explicitly.
Note: If compression is enabled but the resulting compressed content is larger than the original, the message will be sent uncompressed to optimize bandwidth and avoid unnecessary decompression on the subscriber side.
function getSubject
inline String getSubject()
Get the subject of the message.
Return: A string representing the subject of the message
function getContent
inline byte[] getContent()
Get the content of the message.
Return: A byte array representing the content of the message
function getClosure
inline String getClosure()
Get the closure of the message.
Return: The closure data of the message
function isRetained
inline boolean isRetained()
Indicate whether or not the message should be/was retained by the server.
Return: true if the message should be, or was, retained by the server
function getReplySubject
inline String getReplySubject()
Get the subject to be used to reply to this message.
Return: The subject to be used to reply to this message.
A client which receives a message containing a reply subject should interpret the message as a request. It has the option to use the reply subject - extracted from the message with this method - to send a reply.
function getQos
inline QoS getQos()
Get the QoS level of the message.
Return: the QoS level of the message
function getMessageType
inline MessageType getMessageType()
Get the MessageType of the message.
Return: the message type of the message
function setCompressed
inline void setCompressed(
boolean compressed
)
Set whether to compress the content of the message or not.
Parameters:
- compressed if
true
, the content of the message will be published in ZLIB-compressed format; iffalse
no compression format will be used; the default value isfalse
.
Note: If compression is enabled with this method but the size of the content of the message is smaller than the size of compressed content, then the message will be sent uncompressed to save bandwidth and CPU cycles with the decompression on the receiver side.
function getCompressionAlgorithm
inline CompressionAlgorithm getCompressionAlgorithm()
Returns the compression algorithm currently set for the message.
Return: the CompressionAlgorithm set for this message.
function isCompressed
inline boolean isCompressed()
Indicates whether the message should be or was compressed.
On the publisher side, this indicates whether compression should be applied before sending the message. On the subscriber side, this indicates whether the message was received in compressed form. In both cases, if compression is involved, the library automatically handles compression and decompression.
Return: true
if compression is enabled on the publisher side or the message was received compressed on the
subscriber side; false
otherwise.
function toString
inline String toString()
Return a string representation of the message.
Enum CompressionAlgorithm
Represents the available compression algorithms for message payloads.
enum CompressionAlgorithm {
NONE, // No compression applied
ZLIB_BASE64, // ZLIB + Base64 encoding
ZLIB_BINARY // ZLIB + raw binary
};
Enum Values:
- NONE — No compression applied.
- ZLIB_BASE64 — Compression using ZLIB with base64 encoding for UTF-8 transport.
- ZLIB_BINARY — Compression using ZLIB with raw binary output for max efficiency.
Each enum constant is associated with an internal numeric code.