Author: Giovanni Caire (Telecom Italia)
Date: 02/06/2007
This example shows how to use the topic-based message delivery mechanism supported by JADE since version 3.5. By means of this mechanism it is possible to send a message that “is about a given topic” without knowing who will actually receive this message.
The example includes two types of agent:
- the TopicMessageSenderAgent that periodically sends messages about topic “JADE”
- the TopicMessageReceiverAgent that registers to messages about topic “JADE” and prints the content of received messages.
Assuming all jade classes are in the classpath, you can try this example with the following commands:
java jade.Boot -gui -services jade.core.event.NotificationService;jade.core.messaging.TopicManagementService sender:examples.topic.TopicMessageSenderAgent
The above command line starts the JADE Main Container and launches an agent called “sender” of type TopicMessageSenderAgent. The -services option specifies that the TopicManagementService (that implements the topic-based message delivery mechanism) must be activated.
java jade.Boot -container -services jade.core.event.NotificationService;jade.core.messaging.TopicManagementService receiver:examples.topic.TopicMessageReceiverAgent
The above command line starts a JADE container and launches an agent called “receiver” of type TopicMessageSenderAgent. Looking at the output of the two agents it will be possible to see that all messages about topic “JADE” sent by the TopicMessageSenderAgent will be received by the TopicMessageReceiverAgent.