Oracle GlassFish Message Queue 4.4.2 Developer's Guide for Java Clients

Processing Bytes Messages

The body of a bytes message simply consists of a stream of uninterpreted bytes; its interpretation is entirely a matter of agreement between sender and receiver. This type of message is intended primarily for decoding message formats used by other existing message systems; Message Queue clients should generally use one of the other, more specific message types instead.

Reading the body of a bytes message is similar to reading a stream message (see Processing Stream Messages): you use the methods shown in Table 2–24 to decode primitive values from the message’s byte stream. For example, the statement

int  intVal = inMsg.readInt();

retrieves an integer value from the byte stream. The getBodyLength method returns the length of the entire message body in bytes:

int  bodyLength = inMsg.getBodyLength();
Table 2–24 Bytes Message Access Methods

Name 

Description 

getBodyLength

Get length of message body in bytes 

readInt

Read integer from message stream 

readByte

Read signed byte value from message stream 

readUnsignedByte

Read unsigned byte value from message stream 

readBytes

Read byte array from message stream 

readShort

Read signed short integer from message stream 

readUnsignedShort

Read unsigned short integer from message stream 

readLong

Read long integer from message stream 

readFloat

Read floating-point value from message stream 

readDouble

Read double-precision value from message stream 

readBoolean

Read boolean value from message stream 

readChar

Read character from message stream 

readUTF

Read UTF-8 string from message stream