Sometimes it is necessary to send an unformatted stream of bytes as a message. This recipe illustrates this process using the
BytesMessage interface. However, when possible, other message types such as string and objects should be used.
The advantages of using an unformatted stream of bytes include ease of read and write operations and a fixed size message. When data is written or read using the
BytesMessage methods, it is stored using the appropriate primitive data format. For example, when an integer is written, it will be stored as a 32-bit two's complement number. The size of the number will always be four bytes regardless of the number of digits comprising the number.
The essential structure of a ...