private Semaphore obtainPermits(ChannelCachingConnectionProxy connection) { Semaphore permits; permits = this.checkoutPermits.get(connection); if (permits != null) { try { if (!permits.tryAcquire(this.channelCheckoutTimeout, TimeUnit.MILLISECONDS)) { throw new AmqpTimeoutException("No available channels"); } if (logger.isDebugEnabled()) { logger.debug( "Acquired permit for " + connection + ", remaining:" + permits.availablePermits()); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new AmqpTimeoutException("Interrupted while acquiring a channel", e); } } else { throw new IllegalStateException("No permits map entry for " + connection); } return permits; }
private Semaphore obtainPermits(ChannelCachingConnectionProxy connection) { Semaphore permits; permits = this.checkoutPermits.get(connection); if (permits != null) { try { if (!permits.tryAcquire(this.channelCheckoutTimeout, TimeUnit.MILLISECONDS)) { throw new AmqpTimeoutException("No available channels"); } if (logger.isDebugEnabled()) { logger.debug( "Acquired permit for " + connection + ", remaining:" + permits.availablePermits()); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new AmqpTimeoutException("Interrupted while acquiring a channel", e); } } else { throw new IllegalStateException("No permits map entry for " + connection); } return permits; }
if (countOpenConnections() >= this.connectionLimit && System.currentTimeMillis() - now >= this.channelCheckoutTimeout) { throw new AmqpTimeoutException("Timed out attempting to get a connection");
if (countOpenConnections() >= this.connectionLimit && System.currentTimeMillis() - now >= this.channelCheckoutTimeout) { throw new AmqpTimeoutException("Timed out attempting to get a connection");
return new AmqpTimeoutException(ex);