Question

Here is the context: I'm sending a message from one agent (let's say "senderAgent") to another ("targetAgent") : nothing complicated here, or so it seems. The message propagative type is INFORM.

Here is the code for the relevant senderAgent part (inside a one-shot behaviour):

message = new ACLMessage(ACLMessage.INFORM);
message.addReceiver(new AID("targetAgent", AID.ISLOCALNAME));
message.setContent(jsonContent); // not important here
send(message);

And the code for the relevant targetAgent part (inside a cyclic behaviour):

MessageTemplate mt =
        MessageTemplate.and(MessageTemplate.MatchPerformative(ACLMessage.INFORM),
        MessageTemplate.MatchSender("senderAgent", AID.ISLOCALNAME));
ACLMessage msg = receive(mt);

if (msg != null) {
      //do something
    }
block();

Problem is: this message is never caught by the targetAgent. It is indeed sent by my senderAgent but targetAgent's cyclic behaviour always seems to get "null" message (aka "no message").

I used both Jade Console's Sniffer and Introspector tools to investigate.

  • Sniffer shows the message is effectively sent from senderAgent to targetAgent.
  • Introspector even shows the message is sent on sender's side AND received on target side.

Content is alright, AIDs are alright, so why does the targetAgent's cyclic reception behaviour never catch anything?

I feel quite lost as this is my first time having this issue and I successfully implemented similar communication before between other agents of my system...

Any help, debug tips or ideas would be greatly appreciated!

Was it helpful?

Solution

Ok, so my problem was in fact coming from a huge design mistake in my system.

Indeed, I had two Cyclic Behaviours (in targetAgent) waiting for messages with a MessageTemplate matching the same performative and the same sender (senderAgent). These behaviours then both decide wether to do something or not, based on parsed content of the message. Since this was dumb and very bad design, fusing these two agents into one and adding the content-related condition there did the trick.

I found this out by reading the JADE documentation for the "receive" method. When I saw it was "getting a message in the agent's message queue", everything became clear: it there is no message in the queue when I try to receive, it certainly has been received already by another behaviour of the same agent.

Well, case closed!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top