public class Channel extends Object
Channel
realizes the interface for sending messages.
It defines function member SendTo to send a notification to an identified
agent.Notifications are then routed to a message queue where they are stored in chronological order. The Channel object is responsible for localizing the target agent.
Modifier and Type | Field and Description |
---|---|
(package private) static Channel |
channel |
(package private) static Vector<MessageConsumer> |
consumers |
protected org.objectweb.util.monolog.api.Logger |
logmon |
Modifier | Constructor and Description |
---|---|
protected |
Channel()
Constructs a new
Channel object (can only be used by
subclasses). |
Modifier and Type | Method and Description |
---|---|
(package private) void |
directSendTo(AgentId from,
AgentId to,
Notification not)
Sends an immediately validated notification to an agent.
|
(package private) static Channel |
newInstance()
Creates a new instance of channel (result depends of server type).
|
(package private) static void |
post(Message msg)
Adds a message in "ready to deliver" list of right consumer.
|
(package private) static void |
postAndValidate(Message msg) |
(package private) static void |
save()
Save state of all modified consumer.
|
static void |
sendTo(AgentId to,
Notification not)
Sends a notification to an agent.
|
String |
toString()
Returns a string representation of this
Channel object. |
(package private) static void |
validate()
Validates all messages previously dispatched.
|
static Channel channel
protected org.objectweb.util.monolog.api.Logger logmon
static Vector<MessageConsumer> consumers
protected Channel()
Channel
object (can only be used by
subclasses).static Channel newInstance() throws Exception
Channel
's instance.Exception
public static final void sendTo(AgentId to, Notification not)
sendTo
function defined in class Agent
from an agent
code executed during a reaction.
The destination agent receives the notification with a declared null
source agent id, which may be recognized using the isNullId
function of class AgentId
.
This is not true when this call is performed during an standard agent
reaction. In that case the current reacting agent, known by the engine,
is provided as source agent.
The notification is immediately validated, that is made persistent, if it is not sent from an agent reaction. Be careful, does not use this method in the engine thread, sometime engine.agent is null and it throws a NullPointerException.
to
- destination agent.not
- notification.IOException
- error when accessing the local persistent storagestatic final void post(Message msg) throws Exception
msg
- The message to deliver.Exception
static final void save() throws IOException
IOException
static final void validate()
Engine
. The messages are only validated in queues after
the commit of transaction.
Engine.commit()
void directSendTo(AgentId from, AgentId to, Notification not)
MessageConsumer
.
Does not queue the notification in the local message queue.
Normally used uniquely in
sendTo
method.
This function is designed to be indirectly used by secondary threads,
such as Driver
s.
from
- source agent.to
- destination agent.not
- notification.IOException
- error when accessing the local persistent storageCopyright © 2018 ScalAgent D.T.. All Rights Reserved.