If compression is used, the entire message excluding the header is compressed using the bzip2 algorithm
[16]. The
messageSize member of the message header therefore reflects the size of the compressed message, including the uncompressed header, plus an additional four bytes (see
page 1270).
The compressionStatus field of the message header (see
Section 38.3.1) indicates whether a message is compressed and whether the sender can accept a compressed reply, as shown in
Table 38.18.
•
A compression status of 0 indicates that the message is not compressed and, moreover, that the sender of this message cannot accept a compressed reply. A client that does not support compression always uses this value. A client that supports compression sets the value to
0 if the endpoint via which the request is dispatched indicates that it does not support compression.
•
A compression status of 1 indicates that the message is not compressed, but that the server should return a compressed reply (if any). A client uses this value if the endpoint via which the request is dispatched indicates that it supports compression, but the client has decided not to use compression for this particular request (presumably because the request is too small, so compression does not provide any saving).
The message body of a compressed request, batch request, or reply message is encoded by first writing the size of the uncompressed message (including its header) as four-byte integer, followed by the compressed message body (excluding the header). It follows that the size of a compressed message is 14 bytes for the header, plus four bytes to record the size of the uncompressed message, plus the number of bytes occupied by the compressed message body (encoded as specified in Sections
38.3.2 through
38.3.4). Writing the uncompressed message size prior to the body enables the receiver to allocate a buffer that is large enough to accomodate the uncompressed message body.
Note that compression is likely to improve performance only over lower-speed links, for which bandwidth is the overall limiting factor. Over high-speed LAN links, the CPU time spent on compressing and uncompressing messages is longer than the time it takes to just send the uncompressed data.