2.3 High level inter-process communication using Pedro

Initially, when using Qu-Prolog to implement a multi-agent application, inter-agent communication was achieved using Qu-Prolog’s TCP/IP communication primitives. But this inter-agent communication is quite low level. It does not allow agents to be symbolically named with a directory service mapping these symbolic names to TCP/IP connections, as email domain name servers do, nor does it directly support publish/subscribe communication with subscriptions being tests on the content of message notifications. These subscriptions, which could be updated at any time, determine the messages of current interest to the subscribing agent.

In the late 1990s and early 2000s we added interfaces to two servers developed by research groups with whom we were associated to provide this functionality. One offered peer-to-peer communication using email style addresses that identified a particular thread within a name registered agent process, the other offered publish/subscribe communication. However, the two systems used different servers, and the first was no longer being supported and the second became commercial software requiring an annual licence. We therefore decided around 2008 to support both name addressed peer-to-peer communication, and pub/sub communication, using our own a single message routing server process. This server software is called Pedro. It is distributed free with the QuLog/TeleoR software. (http://staff.itee.uq.edu.au/pjr/HomePages/PedroHome.html).

For peer-to-peer communication each Qu-Prolog process has to register with Pedro a symbolic name, such as keith_agent. It must be unique to the host on which the process is running, but other hosts can have processes with the same Pedro registered name. A Qu-Prolog process with Pedro registered name Agent on a host Host has a public identity Agent@Host, for example keith_agent@zeus.doc.ic.ac.uk.

A message term sent may be sent from any thread in one agent process, to a specific thread Th in another, using the destination identification Th:Agent@Host. The message first goes to a Pedro interface in the Qu-Prolog Agent process on Host. It is then put as a new last message in the message queue of the thread Th. If no thread name is given, and the destination is just Agent@Host, the message is put at the back of the message queue of the default message handling thread. This defaults to the initial thread of the process but a Qu-Prolog primitive, set_default_message_thread, allows this to be set to another thread. Unless explicitly set by a call to the primitive.

The publish/subscribe communication is very flexible. Subscriptions have the form:

MessageTermPattern::TestCondition

where TestCondition is a restricted Qu-Prolog query that uses a special set of Pedro supported relations for testing the content of any message that is an instance of MessageTermPattern. To use the pub/sub features a process just has to connect with the Pedro server and optionally lodge a set of subscription rules which may be updated at any time. If the process sends a notification, the server tests it against all the current subscriptions. It forwards the message to all the processes that have a current subscription that covers the notification. The message is then discarded.

Pedro has APIs for C/C++, Java and Python allowing hybrid distributed applications routing messages via a single Pedro server.


On This Site