About JMS Messages

  GigaSpaces 5.X

Documentation Home
Quick Start Guide
Release Notes

Previous release

  Search Here
Searching GigaSpaces Platform 5.X Documentation

                                               

Summary: Messages types, headers, and properties; creating a message.

Message Types

The JMS standard indicates five different message types that an application can publish:

  • Text – contains a java.lang string for transporting string objects, especially XML documents.
  • Object – transports any serializable Java object, either as a Topic or Queue.
  • Stream – transports a stream of Java primitive values, to be filled and read sequentially. It differs from a BytesMessage in that it 'is aware of' the type of the primitives stored on it, and will throw an exception if an attempt is made to read bytes and convert them to the wrong primitive.
  • Map – transports a self-defining set of name-value pairs, where names equal strings and values equal Java primitive types.
  • Bytes – transports a stream of un-interpreted bytes, typically used to duplicate the body of one of the other message types. Useful when one needs to read in raw data from a disk file and transfer it "as is" to another machine and/or location.
New in GigaSpaces 5.1
Compression for the JMS text message body data is supported in GigaSpaces version 5.1 and onwards. The message's body is compressed only if its size is larger than a configured value (threshold). The message's body is compressed when sent, and decompressed when received.

This property is configured via the system property -Dcom.gs.jms.compressionMinSize. The value assigned should be in bytes. The defualt value is 500000 (0.5 MB).

Message Headers

All JMS Messages contain an enduring set of header fields. The header fields hold values employing both clients and providers to identify and route messages. Some header fields are automatically configured by the JMS provider; others may be configured by the JMS client.

Message Properties

Every JMS Message also contains a set of property values. These hold additional information concerning the message. Properties are usually defined by the client application, and are configured by it prior to the message's delivery. JMS standards define many properties that JMS providers may, or may not, configure. JMS providers can also define their own properties.
A message consumer can define a MessageSelector used to filter incoming messages according to property values. For more details, see Message Selectors.

Creating a Message

A Message object is created from a variation of methods of the Session object. For more details, see Javadoc and the five different message types.

// Create an Object message in one step
ObjectMessage om = session.createObjectMessage(anObject);
// Create an Object message in two steps
ObjectMessage om = session.createObjectMessage();
om.setObject(anObject);
// Create a Bytes message
BytesMessage bm = session.createBytesMessage();
// then use various methods on BytesMessage to write bytes to
// the message
// Create a Text message in one step
TextMessage = session.createTextMessage(aString);
// Create a Text message in two steps
TextMessage tm = session.createTextMessage();
tm.setText(aString);
// Create a Stream message
StreamMessage sm = session.createStreamMessage();
// then use various methods on StreamMessage to write bytes
to
// the message
// Create a Map message
MapMessage mm = session.createMapMessage
// then use various methods on MapMessage to write name-value
// pairs to the message

Wiki Content Tree


Your Feedback Needed!

We need your help to improve this wiki site. If you have any suggestions or corrections, write to us at techw@gigaspaces.com. Please provide a link to the wiki page you are referring to.

Labels

 
(None)