There are several message types defined by the JMS specification that the applications can create and receive, all implementing the javax.jms.Message interface.
Generic Message - consists only of a message header and properties.
Byte Message - represents an array of bytes.
Map Message - contains a set of name-value pairs.
Object Message - has a payload that is a Serializable Java object.
Stream Message - contains a stream of Java primitive values.
Text Message - contains java.lang.String object.
Syntax
// create a byte array with the received data byte[] receivedBytes; // create an integer object to receive the data with that specified length: int dataLength; // get the data from the Bytes Message: dataLength = bytesMessage.readBytes(receivedBytes);
Syntax
String stringData; long longData; stringData = mapMessage.getString(“message”); longData = mapMessage.getLong(“long”);
Syntax
String stringValue; long longValue; Class_Implementing_Serialaizable cis = new Class_Implementing_Serialaizable(); cis = objectMessage.getObject(); stringValue = cis.getString(); longValue = cis.getLong();
Syntax
String stringValue; long longValue; stringValue = streamMessage.readString(); longValue = streamMessage.readLong();
Syntax
String text; text = textMessage.getText();