@Override
    public boolean beforeEnqueue(final GatewayQueueEvent event) {
      if (event.getOperation().isRemoveAll()) {
        new Thread(cache::close).start();
        try {
          Thread.sleep(sleepMillis);
        } catch (InterruptedException e) {
          throw new Error(e);
        }
        throw new CacheClosedException("Thrown by CloseCacheGatewayFilter");
      }
      return true;
    }
Override as needed to add to the configuration, such as regionFactory.setOffHeap(boolean).
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerWithFilterDistributedTest.java