|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.iids.aos.systemservices.module.AbstractModule
org.iids.aos.messagecenter.MessageCenter
public class MessageCenter
| Constructor Summary | |
|---|---|
MessageCenter(Communicator _communicator,
AgentScapeConfig config,
AsLookupService lookupService)
|
|
| Method Summary | |
|---|---|
void |
addAgent(AgentID id)
Register AgentID to be available for receiving messages. |
Envelope |
getMessage(AgentID fromId,
java.util.Collection<AgentHandle> handles,
boolean block)
Implementation of HostManager.get_message(org.iids.aos.systemservices.communicator.structs.AgentID, java.util.Collection. |
java.util.List<Envelope> |
getMessages(AgentID fromId,
java.util.Collection<AgentHandle> handles,
boolean block)
Similar to getMessage(org.iids.aos.systemservices.communicator.structs.AgentID, java.util.Collection but it has the possibility of returning
multiple messages (if currently available). |
boolean |
isStarted()
|
void |
putMessage(Envelope env,
boolean canForward)
Drop off a single envelope for an agent. |
void |
putMessages(java.util.List<Envelope> envs,
boolean canForward)
Drop off a set of messages at this message center. |
java.util.List<Envelope> |
removeAgent(AgentID id)
Remove receiver from message center. |
java.util.List<Envelope> |
removeAgentHandle(AgentID id,
AgentHandle... ah)
Removes all messages that are in the queue for a set of handles. |
void |
start()
|
void |
stop()
|
| Methods inherited from class org.iids.aos.systemservices.module.AbstractModule |
|---|
getCommunicator, getModuleName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MessageCenter(Communicator _communicator,
AgentScapeConfig config,
AsLookupService lookupService)
| Method Detail |
|---|
public java.util.List<Envelope> removeAgentHandle(AgentID id,
AgentHandle... ah)
throws AgentIDUnknownException
id - The ID of the agent to remove the handle fromah - The handle to remove all messages for
AgentIDUnknownExceptionpublic void start()
public void stop()
public boolean isStarted()
public Envelope getMessage(AgentID fromId,
java.util.Collection<AgentHandle> handles,
boolean block)
throws AgentIDUnknownException,
AgentUnknownException
HostManager.get_message(org.iids.aos.systemservices.communicator.structs.AgentID, java.util.Collection, boolean) .
Attempts to receive messages from an agent with AgentID
fromId. It only receives messages sent to any of the handles
in handles.
TODO: semantics when handes == null. For now, return an
error (i.e. receive nothing) if there were no handles specified.
fromId - The AgentID of the agent to receive messages from.handles - List of handles to receive from. The handles are assumed to belong
to fromId, though this is not checked. So, if none of
the handles in handles are valid, then nothing will be
received.block - If no messages are available, block and wait until a message becomes
available for this agent, with a handle from handles.
null if there
are no messages available and block == false.
AgentIDUnknownException - If the AgentID is not known to this message center, or
AgentUnknownException - If there are no handles supplied (either null or an
empty list.
public java.util.List<Envelope> getMessages(AgentID fromId,
java.util.Collection<AgentHandle> handles,
boolean block)
throws AgentIDUnknownException,
AgentUnknownException
getMessage(org.iids.aos.systemservices.communicator.structs.AgentID, java.util.Collection, boolean) but it has the possibility of returning
multiple messages (if currently available). This method will block if
needed, and wait for messages. If there is any result, this method will
not block, and return what is currently available in the message queue.
fromId - The Agent to receive messages fromhandles - All handles we want to look out forblock - Block if no result is available
false)
directed to (any of) the handles from the handles argument.
AgentIDUnknownException - If the agent is not known
AgentUnknownException - If (one of) the handle(s) does not belong the the agent.
public void putMessages(java.util.List<Envelope> envs,
boolean canForward)
throws MessageException
canForward is specified to be true.
envs - The envelopes to delivercanForward - Indicates if messages that are not intended for
local agents can be forwarded to a remote message center. This
prevents message centers from bouncing messages for unknown agents
that are still registered in the lookup service.
MessageException - If some of the messages
could not be delivered to their destination.
public void putMessage(Envelope env,
boolean canForward)
throws MessageException
env - The envelope to drop off.canForward - If true then the message may be forwarded
to another message center. This will happen only if the current
message center does not maintain the queue for the target agent.
MessageException - If the message could not be delivered for some reason.
public void addAgent(AgentID id)
throws AgentAlreadyRegisteredException
A message center will only accept messages for agents which IDs are registered here. Once an agent is moved, you can (or must) deregister the ID to collect all of its pending messages.
id - GUID of the agent to register
AgentAlreadyRegisteredException - If the agent was already registered with this message center.
public java.util.List<Envelope> removeAgent(AgentID id)
throws AgentIDUnknownException
Any incoming message will not be enqueued anymore (raises exception).
All pending messages for this agent are returned and cannot be dequeued
anymore by subsequent calls to getMessage(org.iids.aos.systemservices.communicator.structs.AgentID, java.util.Collection.
id - Agent GUID to remove from message center
AgentIDUnknownException - If the agent was not registered with this message center.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||