6.3.1 Message Sends/Receives and Message Addresses

QuLog uses Pedro for sending and receiving messages. For peer-to-peer messages QuLog uses addresses of the form ThreadName : ProcessName @ MachineName for sending messages to threads and ProcessName @ MachineName for sending messages to agents. For agent messages, the message is sent to the default message thread of the agent. By default, this is the initial thread (thread0) but can be changed by the agent using set_default_message_thread.

Agent messages can be shortened to ProcessName if the recipient is on the same machine. The special agent address pedro is for publish-subscribe messages. A publisher would publish using term to pedro and a subscriber would get a message whose sender address is also pedro.

Subscriptions are made using

subscribe(SubscriptionString, ID)

where ID will be bound to the a Pedro gnerated subscription identifier. SubscriptionString is a string representing a Prolog term with an optional :: followed by a Prolog test that is acceptable to Pedro. As an example the call

subscribe("temperature(kitchen, Temp) :: Temp > 30", ID)

will subscribe to temperature messages about the kitchen where the temperature is above 30. The action unsubscribe(ID) will unsubscribe to the subscription with the Pedro identifier ID.

Thread messages can be shortened to ThreadName : ProcessName if the receiver is on the same machine and further to ThreadName if the receiver is on the same process.

In the examples below we assume that appropriate type definintions have been made and the processes have registered their names with Pedro. If this type definition is not made then when an attempt to read such a message is made then the system will raise an input_term_type_error exception.

The action tell(age_of(tim, 3)) to server will send the message to the agent named server on the same machine.

The action seen("Blue Wren") to_thread messages:twitcher@'192.168.0.42' will send the message to the messages thread on the process twitcher on the machine with IP address 192.168.0.42.

Now consider the messages thread on the twitcher process. It could receive the above message in either form below.

Msg from ClientAgent

Msg from_thread ClientThread

In either case the messages thread would suspend until the message arrived and then Msg would be instantiated to seen("Blue Wren"). In the first case ClientAgent would be instantiated to the address of the client agent - i.e. it would not contain the thread name. In the second case ClientThread would be instantiated to the full address (including the thread name). It would depend on what the receiver wanted to do with the sender address in order to decide which of the above receive actions would be best.


On This Site