The problem involves using two android handsets that send messages between them using topic messages. They can receive messages from each other fine if they both use send and have each other's AID. But when a send of a Topic Message function is used, it fails to work.
However, I have a desktop application that can receive the messages from the android platform without a problem. But the android platform can't receive messages from them.
Is there any special step I need to do with Android to receive topic messages?
When creating the profile to connect to JADE, the topic Management Service is setup like below
profile.setProperty(Profile.SERVICES, "jade.core.messaging.TopicManagementFEService");
Any suggestions on troubleshooting this? I used the sniffer to look at this and messages don't get sent between the two android phones. But it definitely gets sent to the PC app.
Looking in the console of the management GUI I see messages going out because I get the following
May 25, 2013 2:21:25 PM jade.core.BackEndContainer messageOut
INFO: [email protected] - Delivering OUT message INFORM, size=431
The JADE Remote Agent Management GUI is running on the desktop with the following arguments
java -cp .;%JADE_JARS% jade.Boot -gui -host %JADE_IP% -port %JADE_PORT% -nomtp -jade_domain_df_autocleanup true -services jade.core.messaging.TopicManagementService;jade.core.event.NotificationService;jade.core.mobility.AgentMobilityService;jade.core.event.NotificationService;jade.imtp.leap.nio.BEManagementService;
The Agents subscribes to a topic with the following code
public void subscribeTopic(String... topics)
{
for (String topic : topics)
{
TopicManagementHelper helper = (TopicManagementHelper) getHelper(TopicManagementHelper.SERVICE_NAME);
if (helper != null)
{
AID topicID = helper.createTopic(topic.toLowerCase());
try
{
helper.register(topicID);
this.subscribedTopics.add(topic.toLowerCase());
}
catch (ServiceException e)
{
logger.log(Level.SEVERE, "Could not subscribe to topic '" + topic + "'.", e);
}
}
}
}
This is the behavior that receives the message using a TickerBehaviour
public void onTick()
{
boolean done = false;
String topic="location";
LocationData navupdate = readTopicMessageContent(topic, ACLMessage.INFORM, LocationData.class);
if (navupdate != null )
{
while (!done){
navupdate = myLocalAgent.readTopicMessageContent(topic, ACLMessage.INFORM, LocationData.class);
if (navupdate == null)
done = true;
}
}
block();
}
The code to send a topic message is
public void sendTopicMessageContent(String topicName, int performative, Serializable object)
{
ACLMessage message = new ACLMessage(performative);
message.setOntology(object.getClass().getName());
message.setContentObject(object);
TopicManagementHelper helper = getTopicManager();
AID rcvr=helper.createTopic(topic.toLowerCase());
message.addReceiver(rcvr);
send(message);
}
See Question&Answers more detail:
os