public synchronized void addSubscription(Subscription subscription){
  if (waitList.isEmpty() && !serviceQueue.isEmpty()) {
    subscription.onPublish(serviceQueue.poll());
  }
 else {
    waitList.putIfAbsent(subscription.getId(),new WaitingSubscription(subscription));
  }
}

public synchronized void addSubscription ( Subscription subscription ) { if ( waitList . isEmpty ( ) && ! serviceQueue . isEmpty ( ) ) { subscription . onPublish ( serviceQueue . poll ( ) ) ; } else { waitList . putIfAbsent ( subscription . getId ( ) , new WaitingSubscription ( subscription ) ) ; } }
add a subscription to the wait list . < p > a subscription should be added to the wait list when either : < p > a ) the previous publish response indicated that there were still more notifications ready to be transferred and there were no more publish requests queued to transfer them . < p > b ) the publishing timer of a subscription expired and there were either notifications to be sent or a keep - alive message to be sent .
