powered by Jive Software

PubSub and <message>


i’m currently trying to use smacks pub/sub system to implement some services for Android.

Basic login, roster, subscribe works great, but updates are currently distributed as stanzas. Now the fun begins.

Unless I’ve missread the PacketReader the logic is hardcoded. Even worse it’s burried in a private method stack, highly interacting with other private methods.

The only options seem to be (1) port the IQ logic or (w) fork the whole XMPPConnection/PacketReader monster.

So here is my question: How did you solve it? Is there something I’ve overseen?

Thanks in advance,


It looks like google/wave is doing the same:


All communication except wavelet updates are sent via PubSub (, “XMPP Publish Suscribe,” September 2008.) [XEP0060] events. Wavelet updates are sent using Message stanzas.

I guess the easiest way would be to merge iq and message parsing into one component that is told about the context (“message” or “iq”) and handles both…

I’ll see what I can do…

What is it that you are trying to do exactly? The specification for XEP-0060 specifies message stanzas for item notifications (although it looks like it will support IQ packets for this purpose as well in the near future), so that part isn’t really a Smack issue.

Typically applications just need to receive the events as they occur and react to them, obviously you are trying to do something different.

The notification of a new item is send to all subscribers inside a stanza, which means I’m getting an inside a .

Now SMACK seems to parse the via PacketParserUtils.parsePacketExtension…

Ok, there is a PacketParserUtils.parsePacketExtension(elementName, namespace, parser));

I’ll recheck this, might be my fault… I’m currently not seeing a call to my logic…

Are you using the release, or a build from trunk?. There is a pubsub API in trunk now that will make using pubsub simple for you.

I’m using my own trunk build github/rtreffer/asmack

Not seeing much of Smack in there, only one class in the src tree.

Here is the documentation for the pubsub extension that is now rolled into Smack to give you an idea of how to use it.

Ok, now it works, I’ve got an error in my IQ/PackageExtension chain and one in my parser. Pubsub working.

I’ve to check how that exception got silenced (or how I’ll detect incorrect parsers in the future)

The src/ folder will be auto-populated with smack-trunk, apache/harmony code and some other stuff.

Afterwards it’s packed into build, patched and compiled for android. Smack-trunk has some nice features, but it heavily breaks android compatibility (SASL & DNS classes aren’t available in Android, same goes for introspection with bean properties). So it’s non-trivial to make it work on Android (at least if you don’t want to go GPL and copy the JSE code).

Login works nicely with googlemail.com, even though this requires just about all patches in the package (DNS/SRV loopup, custom SASL, presence parsing).

I’m now playing around with PubSubManager and message parsing…