There are several message types defined by the JMS specification that the applications can create and receive.
● 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.
// 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); |
String stringData; long longData; stringData = mapMessage.getString(“message”); longData = mapMessage.getLong(“long”); |
String stringValue; long longValue; Class_Implementing_Serialaizable cis = new Class_Implementing_Serialaizable(); cis = objectMessage.getObject(); stringValue = cis.getString(); longValue = cis.getLong(); |
String stringValue; long longValue; stringValue = streamMessage.readString(); longValue = streamMessage.readLong(); |
String text; text = textMessage.getText(); |