How to store pubsub payloads in DB
I am using XMPP pubsub.Everything is working fine.User can create node and interested user can subscribe to开发者_如何学编程 that node.But I want to store the publish action into DB.Because in my application many things are handled by pubsub like chat,feeds etc so on page refresh I want to persist chat.So I m looking for any openfire plugin which saves it into DB behind the scenes. Like openfire saves chat in case of MUC (Multiple User Chat).I dont want to manually send ajax request. So is there any way to log the publish items.
Update:
There was a problem in my form configuration in which persist items was set to false by default.So I configured the node as you suggested.But again I am facing some problem on page refresh.I will explain you with an example. In my application user A logs in and create a node and on successful creation it sends request to user B, now user B subscribe to the node created by user A.Now if any user does a page refresh I send an IQ stanza of type get to get all the missed events like the one you mentioned above.But I am getting error 400 subid-required.
<body rid='430432056' xmlns='http://jabber.org/protocol/httpbind' sid='dca8aafc'><iq to='pubsub.abc' type='get' xmlns='jabber:client' id='3408:sendIQ'><pubsub xmlns='http://jabber.org/protocol/pubsub'><items node='3821poU5zq7nhn1'/></pubsub></iq></body>
In response I am getting:
<body xmlns='http://jabber.org/protocol/httpbind'><iq type="error" id="3408:sendIQ" from="pubsub.abc" to="test@abc/dca8aafc"><pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="3821poU5zq7nhn1"/></pubsub><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><subid-required xmlns="http://jabber.org/protocol/pubsub#errors"/></error></iq></body>
So can help me where I am getting wrong.Also I read the link http://xmpp.org/extensions/xep-0060.html#owner-configure point : 6.5.9.1 which says If the requesting entity has multiple subscriptions to the node but does not specify a subscription ID, the service MUST return a error to the subscriber.So does it mean that I am subscribing to the same node again? I checked if thats the case but I am subscribing only once.So just figuring out where things are getting wrong.
Per XMPP's XEP-0060, it is possible for Owner of the PubSub node to make items on the node expire in a very distant future.
When creating a node, you may want to set the following attributes to make items on the node never expire.
<field var='pubsub#persist_items' type='boolean' label='Persist items to storage'>
<value>1</value>
</field>
<field var='pubsub#max_items' type='text-single' label='Max # of items to persist'>
<value>999999</value>
</field>
<field var='pubsub#item_expire' type='text-single' label='Time after which to automatically purge items'>
<value>999999999999</value>
</field>
Source: http://xmpp.org/extensions/xep-0060.html#owner-configure
Then when you want to retrieve all the items, you can probably do this to retrieve the data:
<iq type='get'
from='francisco@denmark.lit/barracks'
to='pubsub.shakespeare.lit'
id='items1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<items node='princely_musings'/>
</pubsub>
</iq>
Source: http://xmpp.org/extensions/xep-0060.html#subscriber-retrieve-requestall
Would this solve your problem?
精彩评论