private void doPolling() {
    Queue notificationQueue = QueueFactory.getQueue("notification-delivery");

    PushNotificationWorker worker = new PushNotificationWorker(notificationQueue);
    while (!LifecycleManager.getInstance().isShuttingDown()) {
      boolean tasksProcessed = worker.processBatchOfTasks();
      ApiProxy.flushLogs();

      if (!tasksProcessed) {
        // Wait before trying to lease tasks again.
        try {
          Thread.sleep(MILLISECONDS_TO_WAIT_WHEN_NO_TASKS_LEASED);
        } catch (InterruptedException e) {
          return;
        }
      }
    }

    log.info("Instance is shutting down");
  }