1

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 abc-provider@xxx.amazonaws.com abc-provider@xxx.amazonaws.com  "<message from='xyz-customer@xxx.amazonaws.com/2131165549e1bc6553-32b9-4ec4-92bd-c9ed80fb5374' to='abc-provider@xxx.amazonaws.com' 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='xyz-customer@xxx.amazonaws.com/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 abc-provider@xxx.amazonaws.com abc-provider@xxx.amazonaws.com  "<message from='xyz-customer@xxx.amazonaws.com' to='abc-provider@xxx.amazonaws.com' 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"
mohit3081989
  • 441
  • 6
  • 13

1 Answers1

0

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.

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
  • Hi Mickael, I am not trying to have offline delivery, I am trying to push messages on other platform to Ejabberd mysql archive table and executing those messages to get synced in when user comes online. – mohit3081989 Feb 03 '16 at 14:13
  • Then as I mentioned, writing a message in archive or offline storage in MySQL will not route the message through ejabberd. You need to write a custom sync plugin. – Mickaël Rémond Feb 03 '16 at 14:26
  • Hi Mickael, thanks for suggestion, but can you please elaborate more,or can you tell me which particular module to customize in order to load messages from mod_archive, I thought if mod_archive table has all the messages with the format that ejabberd understands, it should be able to read it properly, I am not able to understand, what is restricting ejabberd from it. – mohit3081989 Feb 04 '16 at 03:11
  • No, if you configure ejabberd to read message from MySQL it does not use Mnesia. It is that storage is used only for offline or archived messages. They are only read on reconnect to delivery offline messages or read when user query MAM archive. Database is not a source for routing message (it make no sense). – Mickaël Rémond Feb 04 '16 at 09:51
  • Hey Mickael, If that is the case, it doesn't make sense that ejabberd is not able to even read the messages I have put to mysql. What's blocking ejabberd to read my messages, every single field is specified, created right xml field ? What could be the reason here? And if you are saying that Mysql doesn't involve anyone in between, that why message must go through ejabberd ? – mohit3081989 Feb 04 '16 at 10:08
  • ejabberd reads your messages. You just misunderstand / misread the case where that happens. Everything is explained in my comment. I would only restate the same. – Mickaël Rémond Feb 04 '16 at 10:13
  • It seems to be matter of namespace while sending mam_archive request. The client was using urn:xmpp:mam:0, which was using mnesia and fetching from it only. Changing it to urn:xmpp:mam:1, started fetching data from mysql. – mohit3081989 Feb 04 '16 at 16:43
  • So, in your case, you want to read archive not route messages. – Mickaël Rémond Feb 04 '16 at 21:09