@Override public void close() { if (cacheMode == CacheMode.CONNECTION) { synchronized (connectionMonitor) { if (!this.target.isOpen() || idleConnections.size() >= connectionCacheSize) { if (logger.isDebugEnabled()) { logger.debug("Completely closing connection '" + this + "'"); } if (this.target.isOpen()) { RabbitUtils.closeConnection(this.target); } this.notifyCloseIfNecessary(); openConnections.remove(this); openConnectionNonTransactionalChannels.remove(this); openConnectionTransactionalChannels.remove(this); } else { if (!idleConnections.contains(this)) { if (logger.isDebugEnabled()) { logger.debug("Returning connection '" + this + "' to cache"); } idleConnections.add(this); } } } } }
public void destroy() { if (CachingConnectionFactory.this.cacheMode == CacheMode.CHANNEL) { reset(cachedChannelsNonTransactional, cachedChannelsTransactional); } else { reset( openConnectionNonTransactionalChannels.get(this), openConnectionTransactionalChannels.get(this)); } if (this.target != null) { RabbitUtils.closeConnection(this.target); this.notifyCloseIfNecessary(); } this.target = null; }