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.