CacheEventHandler(NodeEngine nodeEngine) { this.nodeEngine = nodeEngine; GroupProperties groupProperties = nodeEngine.getGroupProperties(); invalidationMessageBatchEnabled = groupProperties.getBoolean(CACHE_INVALIDATION_MESSAGE_BATCH_ENABLED); if (invalidationMessageBatchEnabled) { invalidationMessageBatchSize = groupProperties.getInteger(CACHE_INVALIDATION_MESSAGE_BATCH_SIZE); int invalidationMessageBatchFreq = groupProperties.getInteger(CACHE_INVALIDATION_MESSAGE_BATCH_FREQUENCY_SECONDS); ExecutionService executionService = nodeEngine.getExecutionService(); CacheBatchInvalidationMessageSender batchInvalidationMessageSender = new CacheBatchInvalidationMessageSender(); cacheBatchInvalidationMessageSenderScheduler = executionService.scheduleWithRepetition( ICacheService.SERVICE_NAME + ":cacheBatchInvalidationMessageSender", batchInvalidationMessageSender, invalidationMessageBatchFreq, invalidationMessageBatchFreq, TimeUnit.SECONDS); } LifecycleService lifecycleService = nodeEngine.getHazelcastInstance().getLifecycleService(); lifecycleService.addLifecycleListener( new LifecycleListener() { @Override public void stateChanged(LifecycleEvent event) { if (event.getState() == LifecycleEvent.LifecycleState.SHUTTING_DOWN) { invalidateAllCaches(); } } }); }