protected void setLastDispatchedIDAndRemoveEvents(long lastDispatchedSeqId)
        throws CacheException, InterruptedException {
      Long[] countersCopy = null;
      synchronized (QRM_LOCK) {
        synchronized (this) {
          if (lastDispatchedSequenceId > lastDispatchedSeqId) {
            // If the current last dispatched ID is greater than the new id ,
            // then do not set it
            return;
          }
          lastDispatchedSequenceId = lastDispatchedSeqId;
          if (counters != null) {
            countersCopy = new Long[counters.size()];
            countersCopy = counters.keySet().toArray(countersCopy);
          }
        } // synchronized this

        if (countersCopy != null) {
          for (Long counter : countersCopy) {
            Conflatable event = (Conflatable) owningQueue.region.get(counter);
            if (event == null) {
              // this.destroy(counter); event already destroyed?
              continue;
            }

            long seqId = event.getEventId().getSequenceID();
            if (seqId > lastDispatchedSequenceId) {
              break; // we're done
            }

            if (!owningQueue.destroyFromAvailableIDsAndRegion(counter)) {
              continue; // still valid
            }

            if (event instanceof HAEventWrapper) {
              if (((HAEventWrapper) event).getReferenceCount() == 0 && logger.isDebugEnabled()) {
                logger.debug("Reference count is already zero for event {}", event.getEventId());
              }

              owningQueue.decAndRemoveFromHAContainer((HAEventWrapper) event,
                  "Queue Removal Message");
            }

            // At this point we know we're going to remove the event,
            // so increment the statistic
            owningQueue.stats.incEventsRemovedByQrm();

            if (!owningQueue.shouldBeConflated(event)) {
              // Just update the counters set
              destroy(counter);
              continue; // we're done
            }

            Object key = event.getKeyToConflate();
            String r = event.getRegionToConflate();
            // Update the counters set and the conflation map.
            destroy(counter, key, r);
          } // for
        }
      } // synchronized
    }
Invoked by the by the QRM message . This method sets the LastDispatched sequence ID in the
DACE & destroys all the sequence Ids which are less than the last dispatched sequence ID. At
a time only one thread operates on it which is accomplished by the QRM_LOCK. The lock on the
DACE is minimized by copying the Counters Set & then identifying the positions which need to
be removed

@param lastDispatchedSeqId long indicating the last dispatched ID which gets set in a DACE
geode-core/src/main/java/org/apache/geode/internal/cache/ha/HARegionQueue.java