powered by Jive Software

Retrieving the last 10 messages from the last conversation archive


I’m working on a web based Jabber client and would like to use OpenFire’s conversation archive to load the last 10 messages of the last conversation for example when the user logs in or reloads the page etc.

I can successfully use and to get the last conversation but doesn’t seem to work with to get the last 10 messages in the conversation. See: http://xmpp.org/extensions/xep-0059.html#last. Here are my XMPP messages:

Request the last conversation:


Receive the last conversation:


Request the last 10 messages:


Receive no messages:

If I drop the then I get the first 10 messages:


Looking at the code I think the problem is here: https://github.com/igniterealtime/Openfire/blob/v3.9.3/src/plugins/monitoring/sr c/java/com/reucon/openfire/plugin/archive/xep0136/IQRetrieveHandler.java#L60

Shouldn’t it be something along the lines of:

toIndex = max - resultSet.getBefore().intValue();

fromIndex = toIndex - max;

Also there might need to be special handling as an empty element gets mapped to the long 9223372036854775807L:

https://github.com/igniterealtime/Openfire/blob/v3.9.3/src/plugins/monitoring/sr c/java/com/reucon/openfire/plugin/archive/xep0059/XmppResultSet.java#L51

Prehaps I’m misinterperating how before is supposed to work.

Thanks in advance for any help,

From Richard.