Channel compression in WebSphere MQ classes for JMS

A WebSphere® MQ classes for JMS application can use WebSphere MQ facilities to compress a message header or data.

Compressing the data that flows on a WebSphere MQ channel can improve the performance of the channel and reduce network traffic. Using function supplied with WebSphere MQ, you can compress the data that flows on message channels and MQI channels. On either type of channel, you can compress header data and message data independently of each other. By default, no data is compressed on a channel.

A WebSphere MQ classes for JMS application specifies the techniques that can be used for compressing header or message data on a connection by creating a java.util.Collection object. Each compression technique is an Integer object in the collection, and the order in which the application adds the compression techniques to the collection is the order in which the compression techniques are negotiated with the queue manager when the application creates the connection. The application can then pass the collection to a ConnectionFactory object by calling the setHdrCompList() method, for header data, or the setMsgCompList() method, for message data. When the application is ready, it can create the connection.

The following code fragments illustrate the approach described. The first code fragment shows you how to implement header data compression:

Collection headerComp = new Vector();
headerComp.add(new Integer(WMQConstants.WMQ_COMPHDR_SYSTEM));
.
.
.
((MQConnectionFactory) cf).setHdrCompList(headerComp);
.
.
.
connection = cf.createConnection();
The second code fragment shows you how to implement message data compression:

Collection msgComp = new Vector();
msgComp.add(new Integer(WMQConstants.WMQ_COMPMSG_RLE));
msgComp.add(new Integer(WMQConstants.WMQ_COMPMSG_ZLIBHIGH));
.
.
.
((MQConnectionFactory) cf).setMsgCompList(msgComp);
.
.
.
connection = cf.createConnection();
In the second example, the compression techniques are negotiated in the order RLE, then ZLIBHIGH, when the connection is created. The compression technique that is selected cannot be changed during the lifetime of the Connection object. To use compression on a connection, the setHdrCompList() and the setMsgCompList() methods must be called before creating the Connection object.