code: private int numberOfMessagesToFetch() {
          int numberOfMessagesNeeded = Math.max(numberOfMessagesToPrefetch, messagesRequested);
          return Math.max(numberOfMessagesNeeded - messagesPrefetched, 0);
      }
docs: Determine the number of messages we should attempt to fetch from SQS.
  Returns the difference between the number of messages needed (either for
  prefetching or by request) and the number currently fetched.