Recently we encountered issue where openfire was taking long time to publish event on a node which has got more than 20K subscriptions. Even though we had disabled xmpp.pubsub.multiple-subscriptions’ property.
After analysis I observed that, while publishing event notification to subscribers openfire, for each affiliate Node.getSubscriptions(JID owner) iterate over all subscriptions for a node. This result into 20,000*20,000 iteration while doing single publish.
Rather than directly iterating over all subscriptions for a node, Node.getSubscriptions(JID owner) API should decide which map(subscriptionsByID or subscriptionsByJID) to be used based on isMultipleSubscriptionsEnabled().
Implementation of Node.getSubscriptions(JID owner) should look like:
public Collection getSubscriptions(JID owner) {
Collection subscriptions = new ArrayList();
if(isMultipleSubscriptionsEnabled()){
for (NodeSubscription subscription : subscriptionsByID.values()) {
if (owner.equals(subscription.getOwner())) {
subscriptions.add(subscription);
}
}
}else{
NodeSubscription subscription = getSubscription(owner);
subscriptions.add(subscription);
}
return subscriptions;
}