powered by Jive Software

Roster cache issues


I have written a plugin to add/remove contacts via a web-interface. The plugin uses RosterItemProvider to do the add/remove part.

What I am seeing is that although the updates make it to the database fine - if a IM client logs in (e.g. via Spark) - their contact list hasn’'t been updated. Only after I restart openfire do the updates flow through to the client.

I am thinking this is due to the roster cache - but logic would tell me that if I am going via RosterItemProvider (and not directly to the database) that both the cache and db would get updated.

Any ideas?

Hi Alvin,

Instead of working with the RosterItemProvider it’‘s better to retrieve the User whose roster you’'re altering and make changes to it directly, that way any changes you make will “flow” to the client and their roster. To quote the Roster javadocs:

Updates to this roster is effectively a change to the user’'s roster. To reflect this, the changes to this class will automatically update the persistently stored roster, as well as send out update announcements to all logged in user sessions.

Hope that helps,


The best way is to use:

RosterManager rManager = XMPPServer.getInstance().getRosterManager();

Roster r = rManager.getRoster("username’’);

Once you have the roster API is simple.

Hope this help

I found another solution that may work for you:


You can actually set the cache size and timouts. I’'m using custom providers for groups, for example, so I set:




All to “0”. This is a huge performance hit in regular use cases, but since I’‘m keeping my own cache in my provider, it’'s an ideal solution for me.

Just a thought.