zeus.actors
Class PostMan

java.lang.Object
  extended byjava.lang.Thread
      extended byzeus.actors.PostMan
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
FIPA_PostMan

public class PostMan
extends java.lang.Thread

This component is part of the MailBox, and is responsible for dispatching messages on demand to their recipients. This component operates within its own thread enabling the MailBox to send and receive multiple messages simultaneously.

It is unlikely that developers will need to call these methods directly. Although if the user wants to replace the default TCP/IP messaging mechanism this could be cleanly achieved by reimplementing the methods of this class.


Field Summary
protected  Queue ccMail
          Data structure holding CC'ed messages pending dispatch to Visualisers
protected  boolean dispatching
           
private  boolean fastAgent
           
private static int id
           
protected  int MAX_RETRY
           
protected  MailBox mbox
          Reference to MailBox of which this is a sub-component
protected  Address myAddress
           
protected  Queue outMail
          Data structure holding messages pending dispatch
(package private)  int queueLength
           
(package private)  int sleepTime
           
protected  java.util.Hashtable waitQueue
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
PostMan()
           
PostMan(MailBox mbox, Queue outMail, Address myAddress)
           
PostMan(MailBox mbox, Queue outMail, Queue ccMail, Address myAddress)
           
 
Method Summary
 void addressReceived(java.lang.String key)
           
 void doPost()
           
 void lowerStatus()
           
 boolean postMsg(Performative msg, Address addr)
          postMsg sends the performative out to the other Zeus agent a socket is opened and the message is written as a string down it.
 void push(Performative msg)
          use in preference to postMsg.
 void run()
          this run method is the business end of the agent's communication infrastructure.
 void setFastAgent()
          Some agents need to message quicky, some don't - they need to be sure that there reasoning components get a go at the processor.
 void stopDispatching()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_RETRY

protected final int MAX_RETRY
See Also:
Constant Field Values

outMail

protected Queue outMail
Data structure holding messages pending dispatch


ccMail

protected Queue ccMail
Data structure holding CC'ed messages pending dispatch to Visualisers


mbox

protected MailBox mbox
Reference to MailBox of which this is a sub-component


myAddress

protected Address myAddress

dispatching

protected boolean dispatching

waitQueue

protected java.util.Hashtable waitQueue

id

private static int id

fastAgent

private boolean fastAgent

queueLength

int queueLength

sleepTime

int sleepTime
Constructor Detail

PostMan

public PostMan()

PostMan

public PostMan(MailBox mbox,
               Queue outMail,
               Address myAddress)

PostMan

public PostMan(MailBox mbox,
               Queue outMail,
               Queue ccMail,
               Address myAddress)
Method Detail

stopDispatching

public void stopDispatching()

lowerStatus

public void lowerStatus()

run

public void run()
this run method is the business end of the agent's communication infrastructure. It works in the following way.

for every receiver of the message
if lookupAddress good then
if can send to that address tell the visualisers about the message else post an error and delete that address else ask the nameserver for the address and put this message on a todo list until the nameserver responds then service it.


doPost

public void doPost()

addressReceived

public void addressReceived(java.lang.String key)

setFastAgent

public void setFastAgent()
Some agents need to message quicky, some don't - they need to be sure that there reasoning components get a go at the processor. Call this method on your postman to turn it into a messaging deamon.


postMsg

public boolean postMsg(Performative msg,
                       Address addr)
postMsg sends the performative out to the other Zeus agent a socket is opened and the message is written as a string down it.

The behaviour of this method has been changed for 1.1/2.0 to allow some flexibility on the sender field. This is mostly to allow agents to send messages and stamp them as comming from someone else - in the case of the ACC agent this allows an alias to be set up in the name server for each exterior IIOP/HTTP/WAP/UMTS agent or address of agent that is to be contacted. When the ACC is contacted under this alias it can use it's FIPAAddresBook to lookup an aid and construct a new message for forwarding

To summerise : if the sender name in the msg parameter is set then the sent message will have that sender name, and the address that is returned will also have that name.


push

public void push(Performative msg)
use in preference to postMsg. Whereas the postMsg method invokes the messaging behaviour of the agent directly this method places the message on a Q to be dealt with as and when.
This is a good thing, as it ensures that the agent is not forced into spending all its time just sending messages.....



Copyright © 2000-2003 BT Exact Technologies. All Rights Reserved.