O'Reilly logo

Java Distributed Computing by Jim Farley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Message Processing

When you’re developing an agent that will be exchanging messages, it’s important to think about how message processing will integrate with the rest of the objects making up the agent. Ideally, you’d like to:

Isolate communications details from application details

This leaves you free to design the bulk of the classes making up the application around application issues, not issues related to the communication scheme you happen to be using. Likewise, the communications subsystem can be designed and updated independently, based on the communication needs of the overall system.

Provide a structured way to link messages to method calls on application objects

You need a well-defined way for incoming messages to trigger method calls on application objects, and for object methods to generate messages to remote agents to service requests.

These may seem like conflicting requirements, but we’ll see that they can both be satisfied to one degree or another by a single message-processing method.

Asychronous vs. Synchronous Message Handling

A crucial question in designing a message-processing system is whether it needs to be asynchronous or not. In our chess example, the player agents can process messages synchronously, since they’ll be handshaking throughout the entire game. That is, one player sends a move (in a message) to the other player; the second player applies the move to its copy of the “playing board,” weighs its options, and sends its countermove to the first ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required