ejabberd syncing message from mysql archive

544 views Asked by At

I am working on ejabberd for quite sometime now, I am replacing a third party Chat infra with Ejabberd inhouse. As it was production switch so we need to maintain the previous chat messages while switching to ejabberd.

So I have created all the rosters, migrated users to ejabberd which is all working fine, now main challenge that I am facing is with message migration. I am using mysql for users, rosters and messages. I am running a script which is directly pushing data to ejabberd mysql from previous chat infra.

But when I am connecting to a user, I am able to see new chat messages which were sent through ejabberd, but migrated chats for same user is not visible and not propagated back to client.

Can someone help here ?

Here are the two entries which I had put in mysql, first one is ejabberd entry and other one is manual, client is able to sync first one but not another.

username    timestamp   peer    bare_peer   xml txt id  kind    nick    created_at
xyz-customer    1454573488523175 [email protected] [email protected]  "<message from='[email protected]/2131165549e1bc6553-32b9-4ec4-92bd-c9ed80fb5374' to='[email protected]' xml:lang='en' id='oG3Vb-568' type='chat'><body> CnsfjffsjJ</body><thread>90275196-0096-4bb4-a95d-d72ea5238f74</thread><request xmlns='urn:xmpp:receipts'/><delay xmlns='urn:xmpp:delay' stamp='2016-02-04T08:11:27.194+00:00' from='[email protected]/2131165549e1bc6553-32b9-4ec4-92bd-c9ed80fb5374'/><markable xmlns='urn:xmpp:chat-markers:0'/><request xmlns='urn:urbanclap:request' requestId=''/><active xmlns='http://jabber.org/protocol/chatstates'/></message>"   " CnsfjffsjJ"   208044  chat        "2016-02-04 08:11:28"

xyz-customer    1454570506606317 [email protected] [email protected]  "<message from='[email protected]' to='[email protected]' xml:lang='en' id='I5sO7-2' type='chat'><body>GB hard</body><request xmlns='urn:xmpp:receipts'/><markable xmlns='urn:xmpp:chat-markers:0'/><active xmlns='http://jabber.org/protocol/chatstates'/></message>"    "GB hard"   208045  chat    NULL    "2016-02-04 07:21:46"
1

There are 1 answers

8
Mickaël Rémond On

I guess you are trying to fill the message archive table, but are expecting offline messages delivery. Please, make sure you are adding the message in the right table. I guess you are writing in archive table but should write in spool.

Please note that spool table to deliver offline message is only check on new user login. It is not a way to add messages to deliver to the user in a running session. It means you cannot really sync two running platforms by just writing in MySQL message table. You would need to actually route the messages by writing a custom ejabberd plugin.