Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
185 views
in Technique[技术] by (71.8m points)

java - JADE Leap Android App unable to receive topic messages

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...