@Override public void stop() { this.getLifeCycleLock().writeLock().lock(); try { if (!this.isRunning()) { return; } stopProcessing(); stompProxyDead(); // Close the listeners for (AsyncEventListener listener : this.listeners) { listener.close(); } // stop the running threads, open sockets if any ((ConcurrentParallelGatewaySenderQueue) this.eventProcessor.getQueue()).cleanUp(); logger.info("Stopped {}", this); InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem(); system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_STOP, this); clearTempEventsAfterSenderStopped(); } finally { this.getLifeCycleLock().writeLock().unlock(); } }
/** * Sends a batch of messages to the registered <code>AsyncEventListener</code>s. * * @param events The <code>List</code> of events to send * */ protected boolean dispatchBatch(List events) throws GatewaySenderException { if (events.isEmpty()) { return true; } int batchId = this.eventProcessor.getBatchId(); boolean successAll = true; try { for (AsyncEventListener listener : this.eventListeners) { boolean successOne = listener.processEvents(events); if (!successOne) { successAll = false; } } } catch (Exception e) { final String alias = "%s: Exception during processing batch %s"; final Object[] aliasArgs = new Object[] {this, Integer.valueOf(batchId)}; String exMsg = String.format(alias, aliasArgs); GatewaySenderException ge = new GatewaySenderException(exMsg, e); logger.warn(exMsg, ge); throw ge; } return successAll; }
@Override public void stop() { this.getLifeCycleLock().writeLock().lock(); try { if (!this.isRunning()) { return; } // Stop the dispatcher stopProcessing(); // Stop the proxy (after the dispatcher, so the socket is still // alive until after the dispatcher has stopped) stompProxyDead(); // Close the listeners for (AsyncEventListener listener : this.listeners) { listener.close(); } // stop the running threads, open sockets if any ((ConcurrentParallelGatewaySenderQueue) this.eventProcessor.getQueue()).cleanUp(); logger.info("Stopped {}", this); InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem(); system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_STOP, this); clearTempEventsAfterSenderStopped(); // Keep the eventProcessor around so we can ask it for the regionQueues later. // Tests expect to be able to do this. } finally { this.getLifeCycleLock().writeLock().unlock(); } }
listener.close();
listener.close();
@Override public void destroy() throws Exception { if (!this.cache.isClosed()) { try { this.asyncEventListener.close(); } catch (CacheClosedException ignore) { } } }
@Override public void destroy() throws Exception { if (!this.cache.isClosed()) { try { this.asyncEventListener.close(); } catch (CacheClosedException ignore) { } } }