powered by Jive Software

PEP via PubSub

Hi,

I just need a quick verification from someone who knows the database structure that I’m properly publishing my custom LeafNode objects correctly. I’m following some of the previous threads on PEP and PubSub.

I’m using PubSubManager in Smack to publish a node to ( what I think) is the user’s individual service.

  1. Connect with PubSubManager directly to the client’s JID like this: mPubSubMgr = new PubSubManager(mConnection, userJid);
  2. Publish my object to the desired node, creating if necessary:
protected LeafNode getOrCreateNode(String nodeId) {
          if (!initMgr()) {
               mLogger.warn("getOrCreateNode() failed when attempting 'initMgr()' call");
               return null;
          }
            LeafNode node = null;
          try {
               node = mPubSubMgr.getNode(nodeId);
          } catch (XMPPException e1) {
            mLogger.warn("Unable to get node, creating");
          }
            if (null == node) {
               try {
                    ConfigureForm form = new ConfigureForm(FormType.submit);
                    form.setAccessModel(AccessModel.presence);
                    form.setDeliverPayloads(true);
                    form.setNotifyRetract(false);
                    form.setPersistentItems(false);
                    form.setPublishModel(PublishModel.open);
                    node = (LeafNode) mPubSubMgr.createNode(nodeId, form);
                } catch (XMPPException e2) {
                    mLogger.severe("Could not get node, and could not create either!");
                    e2.printStackTrace();
                    }
          }
          return node;
          }
       /**
     *      * Publishes the user's location to as a PEP event using the PubSub transport.        * @param location
     */
     public void publishLocation(LocationType location) {
          if (!initMgr()) {
               return;
          }           LeafNode node = getOrCreateNode(UserLocationExtension.ELEMENT_NAME);
          if (null == node) {
            mLogger.warn("Not able to recover user's location node... abanoning publishLocation() operation");
            return;
          }
            UserLocationExtension ext = new UserLocationExtension(location);
          UserLocationItem item = new UserLocationItem(ext);           try {
               node.send(item);
          } catch (XMPPException e) {
               e.printStackTrace();
          }
     }

This works successfully, and I’m left with nodes in the Postgresql database:

serviceid (PK)
nodeid
leaf
testuser4@seattle1.foo.bar
Location
1
testuser4@seattle1.foo.bar
testuser4@seattle1.foo.bar
0
pubsub
SomeOtherNode
1
testuser1@seattle1.foo.bar
Location
1
testuser1@seattle1.foo.bar
http://jabber.org/protocol/tune
1

Does this look correct?

Does the fact that the “serviceid” is qualified as the user’s JID ( similar to tune) and NOT as a “pubsub” indicate that I’ve got the user’s PEP node?

Thanks,

DD

That looks correct. PEP nodes do show up with the users jid as the service id.

Thanks,

This leads me to a second question around the same topic.

I’m publishing a “Location” node for each of the users, but getting a strange result. Here’s the debug stream:

1) Query PubSubManager for nodes, like this:

DiscoverItems items = mPubSubMgr.discoverNodes(StringUtils.parseBareAddress(null));

I get the following result:

C2S - RECV (1470360717):

C2S - SENT (1470360717):

<iq type=“result” id=“7B8m5-10” from="testuser1@seattle1.adspore.com"

to="testuser1@seattle1.adspore.com/32cd0338">

2) Attempt to get the node like this:

node = mPubSubMgr.getNode(nodeId);

I get the following result:

C2S - SENT (2146409681):

<iq type=“error” id=“Y43f4-18” from="testuser1@seattle1.adspore.com"

to="testuser1@seattle1.adspore.com/6c955142">

3) Attempt to create the node like this:

node = (LeafNode) mPubSubMgr.createNode(nodeId);

I get the following result:

C2S - RECV (2146409681):

C2S - SENT (2146409681):

<iq type=“error” id=“Y43f4-19” from="testuser1@seattle1.adspore.com"

to="testuser1@seattle1.adspore.com/6c955142">

How is this possible? Initially, I’m getting a 404 (not found), but when I attempt to create that node, I’m getting a conflict!

When initially creating a new user, it works fine until that user disconnects / reconnects. After that it’s all 409’s until I delete the user and recreate.

I’ve been browsing at the Openfire code in the repository, but I don’t see any reason for this.

Thank you again for your help,

Dan, Did you ever figure out this issue? I am having a identical problem. I create a node fine but when I attempt to retrieve it I get a “not found”. If I attempt to recreate it again I get the 409 conflict error.

Michael

Hi Michael,

I did figure it out and I’ve gotten something similar to work.

How deep are you comfortable digging? :slight_smile:

Can chat on the developers conference room if you’d like.

DD