private void addClosingCacheListener(String regionName, int closeAfterCreateKey) {
    assertThat(regionName).isNotEmpty();

    Region<Integer, Integer> region = getCache().getRegion(regionName);
    assertNotNull(region);

    CacheListenerAdapter<Integer, Integer> cacheListener =
        new CacheListenerAdapter<Integer, Integer>() {
          @Override
          public void afterCreate(EntryEvent event) {
            if ((Integer) event.getKey() == closeAfterCreateKey) {
              getCache().close();
            }
          }
        };

    region.getAttributesMutator().addCacheListener(cacheListener);
  }
Test configuration::

Region: Partitioned WAN: Serial Region persistence enabled: false Async channel persistence
enabled: true

No VM is restarted.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/wan/asyncqueue/AsyncEventListenerDistributedTest.java