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 |
---|---|
Get length of message body in bytes |
|
Read integer from message stream |
|
Read signed byte value from message stream |
|
Read unsigned byte value from message stream |
|
Read byte array from message stream |
|
Read signed short integer from message stream |
|
Read unsigned short integer from message stream |
|
Read long integer from message stream |
|
Read floating-point value from message stream |
|
Read double-precision value from message stream |
|
Read boolean value from message stream |
|
Read character from message stream |
|
Read UTF-8 string from message stream |