This is part of a series of small blog posts which will cover some of the smaller, perhaps less likely to be noticed, features of IBM MQ. Read other posts in this series.
Prompted by this question (and subsequently this question) I thought I would write up how to use compression for all the various clients.
Compression is a facility built into IBM MQ channels since V6. There are two types of compression, header compression and message compression. Header compression can simply be turned on or not, the idea being that MQ knows the best way to compress its headers. Message compression has a number of choices which you can pick depending on the type of data you have in your messages. Both ends of the channel have to turn on compression in order for it to be used, although the receiving end can accept several possible compression routines.
To configure queue manager side channels (MCA channels and SVRCONN channels) you can simply use the COMPHDR and COMPMSG attributes on your DEFINE/ALTER CHANNEL commands.
To configure the client end of the channel there are a few different ways to do it depending on which client it is. This blog post aims to summarise the different ways.
Client |
Programmatic interface |
CCDT |
'C' Client |
Set the required values in the HdrCompList and MsgCompList fields in the MQCD structure, point to that from the MQCNO structure and use MQCONNX to connect. See code snippet below. |
✓ |
Java classes Clients |
Assign a collection of compression algorithms to the hdrCompList or msgCompList fields in the MQEnvironment class, as described in Channel compression in IBM MQ classes for Java. |
✓ |
JMS Clients |
Pass a collection of compression algorithms to the connection factory using the setHdrCompList() and setMsgCompList() methods, as described in Channel compression in IBM MQ classes for JMS. |
✓ |
XMS Clients (unmanaged) |
Not supported programmatically, unless you have APAR IJ12614 applied. |
✓ |
XMS Clients (managed) |
Not supported at all, as described in Managed client connections. |
While there is varied support for programmatically selecting channel compression, much broader support exists for using channel compression via the CCDT. This is always a better practice for configuring anything beyond the very basic of channel configuration, and I would always recommend this route anyway. Here's how to configure the client channel in your CCDT.
Run this command using runmqsc -n or MQSCX -n:-
DEFINE CHANNEL(channel-name) CHLTYPE(CLNTCONN) +
CONNAME('ip-addr(port)') +
QMNAME(MQG1) +
COMPHDR(SYSTEM) COMPMSG(ZLIBFAST)
#Little-Gem#IBMMQ#ChampionsCorner