Messages Defined

Before we start discussing message-passing systems, we need to define what we mean by a message. Essentially, a message is a structured piece of information sent from one agent to another over a communication channel. Some messages are requests made to one agent by another, other messages deliver data or notification to another agent. In most applications that we’ll discuss, a message consists of a message identifier and, if needed, a set of message arguments. The message identifier tells the receiver the purpose or type of the message. The arguments to the message contain additional information that is interpreted based on the type of message. They may contain the object of an action (e.g., the message "x y" means, “Do x to y and return the result”), or they may contain information used to carry out a request (e.g., "x a b c " means, “Do x, and use a, b, and c to do it”).

Message identifiers are usually simple, unique tokens that differentiate one type of message from another. They may even be simple integer values, where the agents on either end use a look-up table of some sort to match the value with its meaning. Message arguments, on the other hand, can be of many types. Some simple message protocols get away with using only basic data types, like integers, strings, and floating-point values, for message arguments. These arguments can be read and written directly using the DataInputStream and DataOutputStream classes. Other protocols need to use more complicated ...

Get Java Distributed Computing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.