Topic based communication

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:

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.

 

TopicMessageSenderAgent
Description:
This agent periodically sends messages about topic "JADE".
Jade classes used:
Agent, Topic, TopicManagementHelper, ACLMessage, TickerBehaviour
Source
\src\examples\topic\TopicMessageSenderAgent.java

 

TopicMessageReceiverAgent
Description:
This agent registers to messages about topic "JADE" and prints their content.
Jade classes used:
Agent, Topic, TopicManagementHelper, ACLMessage, MessageTemplate, CyclicBehaviour
Source
\src\examples\topic\TopicMessageReceiverAgent.java

JADE is a trademark of TILAB (formerly CSELT). 
JADE
has been developed jointly by TILAB (formerly CSELT) and the Computer Engineering Group of the University of Parma