Receiving Messages

For receive a message in PADE agents you will need to implement the react() method in your Agent subclass.

Receinving FIPA-ACL messages with PADE framework

In the following example two agents are implemmented. The first is a sender agent in Remetente() class. The role of the sender agent is send one message to receiver agent implemented in Destinatario() class. Note that the react() method is implemented in the receiver agent.

from pade.misc.utility import display_message, start_loop, call_later
from pade.core.agent import Agent
from pade.acl.messages import ACLMessage
from pade.acl.aid import AID
from sys import argv

class Remetente(Agent):
    def __init__(self, aid):
        super(Remetente, self).__init__(aid=aid, debug=False)

    def on_start(self):
        super(Remetente, self).on_start()
        display_message(self.aid.localname, 'Enviando Mensagem...')
        call_later(8.0, self.sending_message)

    def sending_message(self):
        message = ACLMessage(ACLMessage.INFORM)

    def react(self, message):
        super(Remetente, self).react(message)
        display_message(self.aid.localname, 'Mensagem recebida from {}'.format(

class Destinatario(Agent):
    def __init__(self, aid):
        super(Destinatario, self).__init__(aid=aid, debug=False)

    def react(self, message):
        super(Destinatario, self).react(message)
        display_message(self.aid.localname, 'Mensagem recebida from {}'.format(

if __name__ == '__main__':

    agents = list()
    port = int(argv[1])
    destinatario_agent = Destinatario(AID(name='destinatario@localhost:{}'.format(port)))

    port += 1
    remetente_agent = Remetente(AID(name='remetente@localhost:{}'.format(port)))