Retrieving offline messages not working in Smack Client 3.0.4

Hello,

Does anybody has a working example of smack client which can receive offline messages from the server?

I am using Openfire server version 3.3.2 and Smack 3.0.4 on MacOs, connecting to MySQL database on Linux server (this is all test env. for now while I evaluate the API for our needs).

Openfire server is configured for offline messages as follows:

xmpp.offline.type store

xmpp.offline.quota 1048576

I have 2 clients - client A sends messages to client B while client B is not connected. When I connect the client B after ALL messages are written to jiveOffline table, client B doesn’t get them. If I connect first client B, the connect client A and start sending messages, I will get all of them in client B, using either Message or PacketListener, which I assume eliminates connectivity issues.

I assume, I can’t use MessageListener for offline messages associated with Chat object, e.g.

Chat chat = connection.getChatManager().createChat(

connectToNameAtServer, new MessageListener()

{

public void processMessage(Chat chat, Message message)

{

System.out.println(message.getBody());

}

});

so I have created a PackageFilter and PackageListener but I suspect, I maybe using wrong type of filter.

I have tried as simple as:

PacketFilter packetFilter = new ToContainsFilter(username);

PacketListener packetListener = new PacketListener() {

public void processPacket(Packet packet)

{

System.out.println(((Message)packet).getBody());

}

};

connection.addPacketListener(packetListener, packetFilter);

// block main thread so the client doesn’t exit

Thread.sleep(1000 * 60 * 5);

but I also tried more complex filter using AndFilter and OrFilter for MessageClass and either To or From/ContainsFilter and no luck.

Right now I see two options: either my code is incorrect or there is bug in the Openfire server implementation which is bigger issue. Before I start digging into server source code, I am hoping someone can point out mistake in my code and help me fix it quickly.