Chapter 2. Agents

Table of Contents

Transport Stack
Synchronized Communications

TODO: ...

Transport Stack

Control flow for agent actions and messages
Control flow for agent actions and messages

Figure 2.1. Control flow for agent actions and messages


Agent-Blackboard communication is based on two high-level interfaces: AgentActions and AgentMessages. Individually, these interfaces are relatively simple. However, providing an asynchronous two-way communications channel that implements these interfaces is more complex. Figure 2.1 shows the steps involved in this communication process when (a) executing an action and (b) handling a message from the blackboard, when using the XMLOverTCPBlackboard.

Action execution requires the following steps:

  1. The process begins when the agents calls an action method on the transport. The calling thread moves down through the protocol, generates a message, and sends that message. Once control returns to the protocol class, the thread blocks and waits for a reply.

  2. The protocol class has an internal thread responsible for parsing the incoming XML as it arrives from the network via the TCP connection. This thread is already running but remains block until a message arrives from the network.

  3. Once a complete message has arrived, the parser thread processes it.

  4. The message is an action reply, so it is stored in a location where the initiating thread can access it. The initiating thread is then woken.

  5. the initiating thead is resumed. It gets the reply and passes it back to the agent as the return value for the action.

The right-hand diagram shows the sequence of steps for the arrival of a message from the blackboard. These are:

  1. The parser thread has block and is waiting for new information from the blackboard.

  2. Once a completed statement arrives, it parsed and seend to be a message.

  3. The message is passed to the protocol's other internal thread - a QueuedMessageHandler.

  4. The message handler thread repeatedly calls the agent's message functions as new messages arrive. If the thread is busy when new messages arrive, they are simply added to the queue and dealt with in turn. This ensures that the agent is only ever handling a single message from the blackboard at any one time.