MigratoryDataMessage constructor
//// Create a MigratoryDataMessage object.
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.
\param subject the subject of the message
\param content the content of the message
\param closure the closure of the message
\param qos the QoS level of the message; the default is QoS.GUARANTEED
\param retained indicate whether or not the message should be/was retained by the server; the default is true
\param replySubject the reply subject of the message
\param compression Sets whether the content of the message should be compressed, {@code true} to enable compression using {@link CompressionAlgorithm#ZLIB_BASE64} unless already set to {@link CompressionAlgorithm#ZLIB_BINARY}; {@code false} to disable compression.
If {@code true}, compression is enabled using the default algorithm {@link CompressionAlgorithm#ZLIB_BASE64}, unless compression has already been explicitly enabled via compressionAlgorithm parameter with {@link CompressionAlgorithm#ZLIB_BINARY}, in which case the existing algorithm which is more compact is preserved. If {@code false}, compression is disabled (by setting the compression algorithm to {@link CompressionAlgorithm#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 parameter nor compressionAlgorithm is set, compression is disabled by default (i.e. the compression algorithm is set to {@link CompressionAlgorithm#NONE}). \param compressionAlgorithm the compression algorithm to apply . Sets the algorithm that determines whether and how the message is compressed.
Supported values include:
- {@link CompressionAlgorithm#NONE} – disables compression
- {@link CompressionAlgorithm#ZLIB_BASE64} – enables compression with base64 encoding
- {@link CompressionAlgorithm#ZLIB_BINARY} – enables compression in binary form; this provides the most compact payload
This method overrides any previously configured compression setting, including one set by compression.
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 parameter nor compression parameter is set, compression is disabled by default (i.e. the compression algorithm is set to {@link CompressionAlgorithm#NONE}).
Implementation
/// <p>If {@code true}, compression is enabled using the default algorithm {@link CompressionAlgorithm#ZLIB_BASE64},
/// unless compression has already been explicitly enabled via compressionAlgorithm parameter
/// with {@link CompressionAlgorithm#ZLIB_BINARY}, in which case the existing algorithm which is more compact is preserved.
/// If {@code false}, compression is disabled (by setting the compression algorithm to {@link CompressionAlgorithm#NONE}).
///
/// <p><strong>Note:</strong> 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.
///
/// <p><strong>Default behavior:</strong> If neither this parameter nor compressionAlgorithm is set, compression is disabled by default (i.e. the compression algorithm is set to {@link CompressionAlgorithm#NONE}).
/// \param compressionAlgorithm the compression algorithm to apply . Sets the algorithm that determines whether and how the message is compressed.
/// <p>Supported values include:
/// <ul>
/// <li>{@link CompressionAlgorithm#NONE} – disables compression</li>
/// <li>{@link CompressionAlgorithm#ZLIB_BASE64} – enables compression with base64 encoding</li>
/// <li>{@link CompressionAlgorithm#ZLIB_BINARY} – enables compression in binary form; this provides the most compact payload</li>
/// </ul>
///
/// <p>This method overrides any previously configured compression setting, including one set by compression.
///
/// <p><strong>Note:</strong> 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.
///
/// <p><strong>Default behavior:</strong> If neither this parameter nor compression parameter is set,
/// compression is disabled by default (i.e. the compression algorithm is set to {@link CompressionAlgorithm#NONE}).
MigratoryDataMessage(this.subject, this.content,
{this.closure = "",
this.qos = QoS.GUARANTEED,
this.retained = true,
this.replySubject = "",
this.compression = false,
this.compressionAlgorithm = CompressionAlgorithm.NONE}) {
if (compression &&
compressionAlgorithm != CompressionAlgorithm.ZLIB_BINARY) {
compressionAlgorithm = CompressionAlgorithm.ZLIB_BASE64;
}
}