Handling a stream-based message
Sometimes it is desirable to send a stream of primitive values as a message. This recipe illustrates this process using the
The advantages of using a stream of bytes are essentially the same as those for the
BytesMessage: ease of read and write operations and a fixed size message. Data is written or read by storing the data in primitive format. In addition, information about the type of data written is also stored. This means that if an integer is written then only a corresponding integer read operation can be used against the data.
StreamMessage interface differs from the
BytesMessage in that data stored using
StreamMessage interface incorporates information about the data type. This ...