JADE Leap Android App unable to receive topic mess

2019-08-24 17:11发布

问题:

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: BE-192.168.1.114_55555-1@192.168.1.114 - 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);
}

回答1:

After much hair pulling and frustration, I modified the example code titled topic from the JADE download to work with Android. This still didn't work. I posted it to the JADE email list and received the following reply. Please notice for future reference this was with version 4.3.0

Hi,

Actually there was a bug in the way topic registrations from agents in split containers were managed.

Thanks very much for the indication.

The problem should be solved now. In order to get the fix You should get the last JADE sources (server side only: jadeAndroid is not affected at all by this fix) from the JADE SVN repository and recompile the whole.

Let us know if you still have problems.

Bye, Giovanni