This component is an example
SimpleRelay client, which
both sends relays and replies to them.
To use, add this component to an agent and specify a target,
for example in "AgentA" with a target of "AgentB":
<component
name='org.cougaar.core.relay.SimpleRelayExample(target=AgentB)'
class='org.cougaar.core.relay.SimpleRelayExample'
priority='COMPONENT'
insertionpoint='Node.AgentManager.Agent.PluginManager.Plugin'>
<argument>target=AgentB>/argument>
</component>
In the target agent add the component without a target argument:
<component
name='org.cougaar.core.relay.SimpleRelayExample(target=AgentB)'
class='org.cougaar.core.relay.SimpleRelayExample'
priority='COMPONENT'
insertionpoint='Node.AgentManager.Agent.PluginManager.Plugin'/>
You should see output similar to the following, which excludes
logging timestamps and other details:
.. AgentA: Sending (.. query=ping reply=null)
.. AgentB: Reply (.. query=ping reply=echo-ping)
.. AgentA: Received (.. query=ping reply=echo-ping)
It would be straight-forward to extend this example to a more
general remote procedure call (RPC) utility: the query
specifies a String "method" name and Object[] parameters, and
the reply is either a Throwable or a non-error value, plus a
wrapper if the non-error value is null or a Throwable. As in
RMI, the parameters and return value must be Serializable and
treated as immutable.
|