End-to-End Payload Compression
The PubSub+ APIs can perform end-to-end payload compression to allow for:
-
Faster message throughput.
-
Reduced bandwidth usage.
-
Improved performance in your applications.
While end-to-end payload compression creates more work for individual PubSub+ APIs, it enables faster aggregate rates of message publishing and message receiving. The PubSub+ event broker offers transport message compression that compresses the entire message, see Streaming Compressed Connections. However, when you send and receive large messages, compressing the entire message creates a lot of work for the event broker, which can result in slower throughput. If your application needs to send and receive large messages, we recommend you use end-to-end payload compression to improve performance.
Considerations When Compressing Message Payloads
The following sections explain what you should be aware of when you compress message payloads with the PubSub+ Messaging APIs.
-
Use only one form of message compression
-
We recommend you only use one form of compression, either Streaming Compressed Connections through the event broker or end-to-end payload compression through the APIs. Compressing the same message multiple times can waste resources and usually does not result in smaller message sizes.
-
Do not use end-to-end payload compression with small messages
-
End-to-end payload compression works best with messages that are a few megabytes in size. Solace does not recommend using message payload compression with small messages, because end-to-end payload compression can actually increase the size of small messages.
-
Upgrade your publisher and receiver applications
-
Receiver applications automatically decompress any compressed message payloads only if the API supports message payload compression and is updated to the minimum supported version. If your receiver application does not support message payload compression, this can cause potential errors or exceptions. Make sure you update your publisher and receiver applications to the minimum supported versions for payload compression. For version support information, see Feature Support in PubSub+ Messaging APIs.
-
End-to-end payload compression limitations
-
End-to-end payload compression does not currently support PubSub+ Cache.
End-to-end payload compression is not compatible with:
-
SolCache
-
Non-SMF protocols, such as AMQP, HTTP, Kafka and MQTT
If your applications use any of the above, we recommend you do not use end-to-end payload compression.
-
Compressing Message Payloads in the PubSub+ APIs
Your publisher application can compress the binary payload of a message before you publish it. To compress a message payload, you must set a property that tells the API you want end-to-end payload compression enabled. The payload compression level property can be set to an integer from 0-9:
-
0
—Payload compression is disabled. This is the default setting. -
1 - 9
—Payload compression is enabled. 1 is the lowest level of compression with the fastest data throughput, and 9 is the highest level of compression with the slowest data throughput.
Your payload compression level should be adjusted according to your network and performance requirements.
PubSub+ Messaging API | How to set End-to-End Payload Compression Level |
---|---|
JCSMP |
Set JCSMPProperties properties = new JCSMPProperties(); // Payload compression enabled with max compression: properties.setProperty(JCSMPProperties.PAYLOAD_COMPRESSION_LEVEL, Integer.valueOf(9)); For more information, see the PubSub+ Messaging API JCSMP reference. |
Java RTO |
Set ArrayList<String> sessionProperties = new ArrayList<String>(); sessionProperties.add(SessionHandle.PROPERTIES.PAYLOAD_COMPRESSION_LEVEL); sessionProperties.add("9"); // Payload compression enabled with max compression For more information, see the PubSub+ Messaging API Java RTO reference. |
C |
Set sessionProps[propIndex++] = SOLCLIENT_SESSION_PROP_PAYLOAD_COMPRESSION_LEVEL; sessionProps[propIndex++] = "9"; /* Payload compression enabled with max compression */ For more information, see the PubSub+ Messaging API C reference. |
.NET |
Set SessionProperties sessionProps = new SessionProperties() { // SessionProperties // ... PayloadCompressionLevel = 9 // Payload compression enabled with max compression }; For more information, see the PubSub+ Messaging API .NET reference. |
JavaScript and Node.js |
Set publisher.session = solace.SolclientFactory.createSession({ // solace.SessionProperties // ... payloadCompressionLevel: 9 // Payload compression enabled with max compression }); For more information, see the PubSub+ Messaging API JavaScript reference. |