code: public void publishAllOutstanding() {
      messagesBatchLock.lock();
      OutstandingBatch batchToSend;
      try {
        if (messagesBatch.isEmpty()) {
          return;
        }
        batchToSend = messagesBatch.popOutstandingBatch();
      } finally {
        messagesBatchLock.unlock();
      }
      publishOutstandingBatch(batchToSend);
    }
docs: Publish any outstanding batches if non-empty. This method sends buffered messages, but does not
  wait for the send operations to complete. To wait for messages to send, call {@code get} on the
  futures returned from {@code publish}.