@Override
  public Object take() throws CacheException, InterruptedException {
    Conflatable object = null;
    Long next;
    if ((next = getAndRemoveNextAvailableID()) != null) {
      object = (Conflatable) region.get(next);
      Assert.assertTrue(object != null);

      object = getAndRemoveFromHAContainer(object);
      Assert.assertTrue(object != null);
      EventID eventid = object.getEventId();
      long sequenceId = eventid.getSequenceID();
      ThreadIdentifier threadid = getThreadIdentifier(eventid);
      DispatchedAndCurrentEvents dace = (DispatchedAndCurrentEvents) eventsMap.get(threadid);
      Assert.assertTrue(dace != null);
      Object keyToConflate = null;
      if (shouldBeConflated(object)) {
        keyToConflate = object.getKeyToConflate();
      }
      dace.removeEventAndSetSequenceID(
          new RemovedEventInfo(next, object.getRegionToConflate(), keyToConflate), sequenceId);

      // Periodic ack from the client will add to the addDispatchMessage Map.
      // This method gets called from cacheClientNotifier upon receiving the ack from client.
      // addDispatchedMessage(threadid, sequenceId);

      // update the stats
      // if (logger.isDebugEnabled()) {
      stats.incEventsTaken();
      // }
    }
    // since size is zero, return null
    if (object == null && logger.isDebugEnabled()) {
      logger.debug("RegionQueue is EMPTY, returning null for take()");
    }
    return object;
  }
For non blocking queue , this method either returns null or an Object. For blocking queue it
will always return with an Object or wait for queue to be populated.

@throws CacheException The exception can be thrown by BlockingQueue if it encounters
        InterruptedException while waiting for data
geode-core/src/main/java/org/apache/geode/internal/cache/ha/HARegionQueue.java