I am having a problem with an application using Smack 3.1 and a server running openfire. Upon starting the application, it will read the last message on the node. This doesn't work since the messages are parsed, processed and placed into a db. Besides sending a message creation time in the payload, is there any way to stop this duplication? (Actually if there is anyway to signal that a message has been "consumed" would be fantastic)
A:
If you are referring to pubsub then you can either configure the node so that it does not persist items with persist_items
and max_items
.
If you have no control over the node creation then what you can do is check for the delay namespace (jabber:x:delay
and/or urn:xmpp:delay
) in the packet
public void processPacket(Packet pkt) {
DelayInformation delay = (DelayInformation)pkg.getExtension("x", "jabber:x:delay");
if (delay != null)
return; //Discard this packet
delay = (DelayInformation)pkg.getExtension("x", "urn:xmpp:delay");
if (delay != null)
return; //Discard this as well
//Otherwise this is a good packet
...
}
You can also make some decision by examining the DelayInformation
object as to how long, reason, etc.
If it is PEP then you will always get the last item published and I think there is no way of determining if it was delayed viz. there is no delay info in the packet.
You need to either get nightly builds or build your own for pubsub support. I don't think the current version Smack 3.1.0 supoorts pubsub.
Chuk Lee
2010-09-22 03:18:45
When you said pubsub it sparked my memories and a quick browse through the maven dependencies reveals that we are using smackx-pubsub .4. I am still poking about but you have gotten me a world closer (and if this works out, an accepted answer)
Bobnix
2010-09-22 12:56:05