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.

  1. Considerations When Compressing Message Payloads

  2. Compressing Message Payloads in the PubSub+ APIs

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.

The table below shows how to set the end-to-end payload compression property in your publisher applications:

PubSub+ Messaging API How to set End-to-End Payload Compression Level

JCSMP

Set JCSMPProperties.PAYLOAD_COMPRESSION_LEVEL when you configure your session properties. For example:

JCSMPProperties properties = new JCSMPProperties();	
properties.setProperty(JCSMPProperties.PAYLOAD_COMPRESSION_LEVEL, Integer.valueOf(9)); // Payload compression enabled with max compression					

For more information, see the PubSub+ Messaging API JCSMP reference.

Java RTO Not currently supported
JMS Not currently supported

C

Set SOLCLIENT_SESSION_PROP_PAYLOAD_COMPRESSION_LEVEL when you configure your session properties. For example:

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 Not currently supported
JavaScript and Node.js

Set payloadCompressionLevel when you configure your session properties. For example:

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.