views:

268

answers:

1

The subscriber will only receive content from the moment he is subscripting to a node and all old content published by publisher will not be received by subscriber. Is this correct? May i know, what do i need to do in order for subscriber to receive all previous old content ?

+3  A: 

You can configure your nodes to be persistent or transient. According to the specifictaion (XEP-0060):

Whether the node is persistent or transient is determined by the "pubsub#persist_items" configuration field.

However, your pubsub service (or server) might be configured to ignore persistence of events. (If you're using Openfire, I think there is a configurable limit for the maximum total size of stored items)

As I know you are using smackx-pubsub, here's some code:

// create new node
pubSubManager.createNode(nodeId, newConfigureForm(persistent, includePayload, accessModel)

// change existing node
node.sendConfigurationForm(newConfigureForm(persistent, includePayload, accessModel));

private ConfigureForm newConfigureForm(final boolean persistent, final boolean includePayload, final AccessModel accessModel) {
  final ConfigureForm form = new ConfigureForm(FormType.submit);
  form.setPersistentItems(persistent);
  form.setDeliverPayloads(includePayload);
  form.setAccessModel(accessModel);
  return form;
}

PS: Can you tell me why I get the feeling that we're doing a kind of pair programming here? ;)

sfussenegger
you are helpful :\
cometta
@cometta and @sfussenegger - You left out that to get the old items, you have to do a node.getItems(). Also, instead of the github version you should build Smack from it's source (http://www.igniterealtime.org/downloads/source.jsp) to get the latest version of the pubsub code.
Robin
@Robin so pubsub is finally coming out of the box? starting from version 3.2?
sfussenegger