0
votes

I have ejabberd as my local server and smack as the android side api.

When user comes online and there is number of offline messages to deliver , the ejabberd server just floods me with the messages .and i get every message but the order is just not perfect. the order in which message is sent and saved in server is not how i receive the messages.

I can handle the offline messages on smack by the OfflineMessageManager class . but this is not supported in ejabberd. i used supportsFlexibleRetrieval() to check it and it returned false.

I also checked it with the Xabber android app and surprisingly here i get all the messages in correct order from the ejabberd server. so the problem is at my android client side. my receiver is as follows-

PacketListener myListener;
String new_msg_body, new_msg_from;

final StanzaFilter filter = new AndFilter(new StanzaTypeFilter(Message.class));

        PacketCollector myCollector = conn1.createPacketCollector(filter);

        myListener = new PacketListener() {
            @Override
            public void processPacket(Stanza packet) throws SmackException.NotConnectedException {
                Message msg = (Message) packet;
                new_msg_body = msg.getBody();
                new_msg_from = msg.getFrom();
                Log.i("log", "message recived :" + new_msg_body + " from : " + new_msg_from +" msg id : " + msg.getStanzaId());
            }
        };

        conn1.addPacketListener(myListener, filter);

Do any one have any suggestion for this problem.

Progress

Till now i have found that each message has its id and the ids of each message is in order if their sending time. so i can may be do a sorting here to get the messages in order.

got to know that each packet that comes that fires its own receiver instance. and this will make the device flood with number of messages at a time . this might be causing the problem.

2

2 Answers

1
votes

ejabberd 16.02 or latest version support Flexible Offline Message Retrieval (XEP-0013) .download and install latest version of ejabberd. check this link

0
votes

XEP-0013: Flexible Offline Message Retrieval is from 2003, maybe it is time to move to the much more modern XEP-0313: Message Archive Management? It is far better for multiple devices environments, such as the concurrent use of mobile and web apps.

MongooseIM has a strong support for MAM: MongooseIM 1.6.2 supports MAM v0.2, but our master branch (next version) supports MAM v0.5.1. You can store your message archive in MySQL, PostgreSQL, Riak KV, and Cassandra!