migratorydata::MigratoryDataMessage
Represent a message.
#include <client-cpp/MigratoryDataMessage.h>
Public Classes
Name | |
---|---|
enum | MessageType The message type received from MigratoryData server. |
enum | CompressionAlgorithm The available compression algorithms for message payloads. |
Public Functions
Name | |
---|---|
MigratoryDataMessage() Default constructor. |
|
MigratoryDataMessage(const MigratoryDataMessage & message) Copy constructor. |
|
MigratoryDataMessage(const std::string & subject, const std::string & content) Create a MigratoryDataMessage object. |
|
MigratoryDataMessage(const std::string & subject, const std::string & content, const std::string & closure) Create a MigratoryDataMessage object. |
|
MigratoryDataMessage(const std::string & subject, const std::string & content, const std::string & closure, QoS qos, bool retained, const std::string & replySubject) Create a MigratoryDataMessage object. |
|
std::string | getSubject() const Get the subject of the message. |
std::string | getContent() const Get the content of the message. |
std::string | getClosure() const Get the closure of the message. |
bool | isRetained() const Indicate whether or not the message should be/was retained by the server. |
std::string | getReplySubject() const Get the subject to be used to reply to this message. |
QoS | getQos() const Get the QoS level of the message. |
MessageType | getMessageType() const Get the MessageType of the message. |
void | setCompressed(bool compressed) Sets whether the content of the message should be compressed. |
void | setCompressionAlgorithm(CompressionAlgorithm algorithm) Sets the algorithm that determines whether and how the message is compressed. |
CompressionAlgorithm | getCompressionAlgorithm() const Returns the compression algorithm currently set for the message. |
bool | isCompressed() const Indicates whether the message should be or was compressed. |
std::string | toString() const Return a string representation of the message. |
virtual | ~MigratoryDataMessage() Destructor. |
Protected Attributes
Name | |
---|---|
int | seq |
int | epoch |
MessageType | messageType |
Public Functions Documentation
function MigratoryDataMessage
MigratoryDataMessage()
Default constructor.
function MigratoryDataMessage
MigratoryDataMessage(
const MigratoryDataMessage & message
)
Copy constructor.
Parameters:
- message A MigratoryDataMessage object
function MigratoryDataMessage
MigratoryDataMessage(
const std::string & subject,
const std::string & content
)
Create a MigratoryDataMessage object.
Parameters:
- subject The subject of the message
- content The content of the message
function MigratoryDataMessage
MigratoryDataMessage(
const std::string & subject,
const std::string & content,
const std::string & closure
)
Create a MigratoryDataMessage object.
Parameters:
- subject The subject of the message
- content The content of the message
- closure The closure of the message (OPTIONAL)
function MigratoryDataMessage
MigratoryDataMessage(
const std::string & subject,
const std::string & content,
const std::string & closure,
QoS qos,
bool retained,
const std::string & replySubject
)
Create a MigratoryDataMessage object.
Parameters:
- subject The subject of the message
- content The content of the message
- closure The closure of the message (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 (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.
function getSubject
std::string getSubject() const
Get the subject of the message.
Return: A string representing the subject of the message
function getContent
std::string getContent() const
Get the content of the message.
Return: A string representing the content of the message
function getClosure
std::string getClosure() const
Get the closure of the message.
Return: The closure data of the message
function isRetained
bool isRetained() const
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
std::string getReplySubject() const
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
QoS getQos() const
Get the QoS level of the message.
Return: the QoS level of the message
function getMessageType
MessageType getMessageType() const
Get the MessageType of the message.
Return: the message type of the message
function setCompressed
inline void setCompressed(bool compressed)
Sets whether the content of the message should be compressed.
If true
, compression is enabled using the default algorithm ZLIB_BASE64
,
unless compression has already been explicitly enabled via setCompressionAlgorithm()
with ZLIB_BINARY
, in which case the existing algorithm – which is more compact – is preserved.
If false
, compression is disabled (i.e., compression algorithm is set to NONE
).
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.
Default behavior: If neither this method nor setCompressionAlgorithm()
is
called, compression is disabled by default (i.e. the compression algorithm is set to NONE
).
Parameters:
compressed
—true
to enable compression usingZLIB_BASE64
unless already enabled withZLIB_BINARY
;false
to disable.
function setCompressionAlgorithm
inline void setCompressionAlgorithm(CompressionAlgorithm algorithm)
Sets the algorithm that determines whether and how the message is compressed.
Supported algorithms:
NONE
— disables compressionZLIB_BASE64
— enables compression with base64 encodingZLIB_BINARY
— enables binary compression (most compact)
This method overrides any previously configured compression setting, including one set
by setCompressed()
.
Note: If compression results in a larger payload, the message will be sent uncompressed.
Default behavior: If neither this method nor setCompressed()
is
called, compression is disabled by default (i.e. the compression algorithm is set to NONE
).
Parameters:
algorithm
— the CompressionAlgorithm to apply.
function getCompressionAlgorithm
inline CompressionAlgorithm getCompressionAlgorithm() const
Returns the compression algorithm currently set for the message.
The returned value reflects the current compression setting of the message, whether it was set via
setCompressed()
and/or setCompressionAlgorithm()
.
Return: the CompressionAlgorithm set for this message.
function isCompressed
inline bool isCompressed() const
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
std::string toString() const
Return a string representation of the message.
function ~MigratoryDataMessage
virtual ~MigratoryDataMessage()
Destructor.
Protected Attributes Documentation
variable seq
int seq;
variable epoch
int epoch;
variable messageType
MessageType messageType;
Enum CompressionAlgorithm
#include <client-cpp/MigratoryDataCompressionAlgorithm.h>
Represents the available compression algorithms for message payloads.
enum class CompressionAlgorithm {
NONE = 0, // 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.