powered by Jive Software

Storing messages with openfire and smack

Hello to all!

I am developing an application through the XMPP smack library and openfire server. wondered if it is possible to store chat conversations in the openfire server, or do I have to store in a database on your own?

thanks for listening!

1 Like

There is an openfire plug-in that can do this.

1.Go into your admin console (yourserver.com:9090), login and click on the “Plugins” option

2.Scroll down the list and find the one called “Monitoring Service”, click on the check mark to install it

3.Once installed, a new tab will appear under “Server -> Archiving”

4.Once in the Archiving tab, click on the “Achiving Settings”, check the “Archive one-to-one chats”

5.Now, go back to the “Search Archive” option, and click on search, DONE!

These messages are stored in the openfire database in mysql (I used mysql during server setup, I didn’t use the default database). If you want to check it, ssh into your server:

  1. mysql -u username -p password

  2. inside mysql, type “select openfire;” (I named my databasae for the openfire server as “openfire")

  3. enter “show tables;”, you should see a table called “ofMessageArchive” and this is the table for storing the converstations

Oh thank you, and how can I get these conversations on the client?

I don’t understand what you mean. Please be more explicit.

Oh sorry for my vocabulary, do not speak fluently in English … It turns out you wanted to filter the message history in my chat application. I wanted to show old messages sent by users, and wanted to know what procedures through programming by smack library should I follow to retrieve this information (history). Thanks for listening Cheng

I don’t think you can do that in Smack.

What I can think of is to write a porgram that runs on the server itself. The program will logon as a user and respond to request.

You add this program as a friend on your side and send command to it so that the program can fetch database record for you and send it back.

You have to decide, if you want to store messages (centralized) on the server or on each client.

We have solved this problem with a client-side database, where we store all messages. Users can then search the database for old messages and display a history of old conversations.

Advantage: It is relatively fast. No need for XMPP traffic.

Disadvantage: Messages are only stored per client (i.e. device). E.g. if a user uses multiple devices with multiple XMPP resources and switches during a conversation, he will have half of the conversation on device 1 and the other half on device 2.

For server side storage, you need XMPP queries. Everytime you display a chat history you need to ask the server. There’s even http://xmpp.org/extensions/xep-0136.html but I don’t know if Openfire and/or Smack does support it.

Too bad … I consulted the protocols supported by Openfire (http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/protocol -support.html) and there is no reference XEP-0136. The only reasonable solution I see is to make a web service that consumes the external database of openfire, where it will create additional tables MESSAGES, so the web service queries return only historic, it would not be appropriate armazer the internal database (SQLite because my application will be for devices), so I think it would be a good move … do you think the most correct thing to do?

Hello to all!

This is the process to store chat conversations in mysql database. Can It’s possible to store chat conversations in Oracle database?