YPService simple example
Einhuf
einhuf at gmail.com
Wed Aug 8 02:35:30 EDT 2007
Thank you, I don´t need this complex example. I wrote a little framework,
where I use message passing by the blackboard and it works well. The only
thing what I had to consider was: If you call the blackboard from a
different thread some error occurs like ("calling blabla from external
transaction - or something like that). Because some agents should provide
user input I used user interfaces and they run on a different thread than
cougaar. Now I´m using this for each message passing:
blackboard.openTransaction();
blackboard.publishAdd(message);
blackboard.closeTransaction();
What I really would still need is a simpler example of the DF (YPService). I
don´t know what the structure/schema is of the owl-s files, if I had to
produce the wsdl by myself or if they are even necessary and many other open
questions, where I am not sure if things are needed or if they come from
another feature the pizza example wants to show. My version don´t run and no
meaningful (to me) error message is produced.
I would like to have a really simple example or step by step tutorial to see
what components are required and which not. The pizza example includes
features I don´t need, but I cannot follow all steps. But it seems like
there are no simple, single (not a whole usecase with many features shown)
examples for the basic features. Because I have pressure of time I can´t
spend more time on the YP. I have to simulate an easy own broker by a simple
lookup agent. But if anybody has some code, where I can get some hints to
understand it better, please send it to me.
Thanks and greetz from munich,
Thomas
Einhuf wrote:
> Hi again,
> I only want to send messages from a sender to a receiver agent
> (currently inside one node on one computer). I only found the ping
> example to send messages and the MTS Service. But the documentation
> doesn´t include themes like "how to use" or examples. And the api
> Message Transport Service online manuel isn´t reachable ( The requested
> URL
> /software/latest/javadoc
/mtsstd/doc/OnlineManual/MessageTransport/index.html
Here's a link to the online copy:
http://cougaar.cougaar.org/software/latest/OnlineManual/MessageTransport/
> was not found on this server.) Has anybody a link or code for the usage
> of that service. Or would you use the ping example via blackboard to
> communicate with other agents?
I recommend using the blackboard, as discussed in the overview slides:
http://cougaar.org/docman/view.php/17/196/CougaarOverview.ppt
and in the example code:
http://build.cougaar.org/auto/HEAD/latest_success/demo-ping.zip
Blackboard relays are analogous to inter-agent messages.
However, if you prefer, you can use raw messaging. Your component can
get the agent's MessageSwitchService:
http://cougaar.cougaar.org/software/latest/javadoc/core/doc/api/org/cougaar/core/agent/service/MessageSwitchService.html
The "sendMessage" method is easy to use. Receiving messages is more
complicated -- you must add a "MessageHandler" that processes the
messages on a separate thread, to avoid blocking the Message Transport.
The code should look similar to:
public boolean handleMessage(Message m) {
if (!(m instanceof MyMessage)) return false;
synchronized (queue) { queue.add(m); }
schedulable.start(); // ThreadService pooled thread for our "run()"
return true;
}
...
public void run() {
synchronized (queue) { tmp.addAll(queue); queue.clear(); }
for (Message m : tmp) {
// process the message!
}
tmp.clear();
}
I can provide a complete example if you're interested. However, I think
that the blackboard approach is both easier to use and more flexible.
Todd
>
>
> Thanks,
> Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cougaar.org/pipermail/cougaar-developers/attachments/20070808/8e75e2ee/attachment.html
More information about the Cougaar-developers
mailing list