Handling Multiple Presences in Openfire


XMPP is a terrific protocol for communications based media. For P2P networking, it is the or at least among the most robust. Well supported distributions like the ultralight eJabberd and extensive though somewhat resource intensive Openfire exist which implement the 20 year old protocol to a tee.

Still, there is that nagging need to detect multiple statuses at once to avoid overburdening resources with what could be thousands of extra requests. This article examines how to poll for multiple presences at once by extending Openfire’s presence service with a JSON plugin.

Code is available on my Github account.

Presence API

JiveSoftware, creator of the presence plugin, created a decent and simple presence API whose code is available on Github.

This API is easy to extend.

Using my plugin

My plugin simply adds a few lines to the PresencePlugin class and creates a JSONPresenceProvider class that can be used to return one or more statuses.

The available options are:

  • jid: Takes presidence and obtains the status of a single JID
  • jids: A semi-colon (;) separated list of jids of which to obtain statuses
  • type: This should be json to obtain the list of statuses

For instance:


This allows GET requests to be kept fairly simple. The same parameters may be used in a POST request as before.

Values are returned in a JSON object containing an array of user information objects:

     "user": "username",
     "jid": "username@server",
     "status": "[available | unavailble | etc.]"
  "success": [true | false]


Building the plugin is simple on Linux (or Windows). Simply execute the following on Linux at the root of the project.

 mvn clean package
 cd ./target
 mkdir build
 mv presence*jar ./build
 cd ./build && jar -xvf presence.jar && jar -xvf presence-X.X.X.jar
 mv *jar ../
jar -cvf presence.jar .

This will combine the dependency and code jar into a single jar which can be placed in the plugins folder of Openfire. Openfire automatically detects new plugins.


Extending Openfire is simple. This article reviewed my modification to the presence plug-in allowing users to obtain the status of multiple JIDS at once through JSON.