Configuring Message Compression

This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Configuring Message Compression

All messages published to WSO2 MB are stored in a database, which guarantees message persistence. From WSO2 MB 3.1.0 onwards, you can reduce the overhead on the database by compressing (i.e., reducing the message content size) the messages using LZ4 compression. This will reduce the number of message content chunks, which in turn will reduce the number of records in the database. This is an optional configuration that you can set up in the message broker. 

Find out more about how this configuration improves the performance of your MB server.

Follow the steps given below to enable message content compression for your server.

  1. Open the broker.xml file from the <MB_HOME>/repository/conf directory.

  2. Enable compression by setting the following property to 'true'.

    <!-- This is the configuration to allow compression of message contents, before store messages into the database.--> <allowCompression>false</allowCompression>
  3. Specify the message content compression threshold using the following parameter. This is the minimum content size a message should have in order to be compressed. Messages smaller than this size will not be compressed, even if compression is enabled for the server.

    <!-- This is the configuration to change the value of the content compression threshold (in bytes). Message contents less than this value will not compress, even compression is enabled. The recommended message size of the smallest message before compression is 13 bytes. Compress messages smaller than 13 bytes will expand the message size by 0.4% --> <contentCompressionThreshold>1000</contentCompressionThreshold>
  4. Specify values for the following parameters, which will determine the speed of the message sending mechanism:

    • The <parallelDecompressionHandlers> parameter specifies the total number of parallel decompression handlers that are used to decompress the message content before they are sent to subscribers. 

    • The <parallelContentReaders> parameter specifies the number of parallel readers used to read content from the message store.

    • The <parallelDeliveryHandlers> parameters specifies the number of parallel delivery handlers used to deliver messages to subscribers.

    <parallelDecompressionHandlers>5</parallelDecompressionHandlers> <parallelContentReaders>5</parallelContentReaders> <parallelDeliveryHandlers>5</parallelDeliveryHandlers>