Example 3–1 shows how you set and send a compressed message:
//topicSession and myTopic are assumed to have been created
topicPublisher publisher = topicSession.createPublisher(myTopic);
BytesMessage bytesMessage=topicSession.createBytesMessage();
//byteArray is assumed to have been created
bytesMessage.writeBytes(byteArray);
//instruct the client runtime to compress this message
bytesMessage.setBooleanProperty("JMS_SUN_COMPRESS", true);
//publish message to the myTopic destination
publisher.publish(bytesMessage);
|
Example 3–2 shows how you examine compressed and uncompressed message body size. The bytesMessage was created as in Example 3–1:
//get uncompressed body size int uncompressed=bytesMessage.getIntProperty(“JMS_SUN_UNCOMPRESSED_SIZE”); //get compressed body size int compressed=bytesMessage.getIntProperty(“JMS_SUN_COMPRESSED_SIZE”); |