/** * Get the channel holder associated with a direct reply-to consumer; contains a * consumer epoch to prevent inappropriate releases. * @return the channel holder. */ public ChannelHolder getChannelHolder() { synchronized (this.consumersMonitor) { ChannelHolder channelHolder = null; while (channelHolder == null) { if (!isRunning()) { throw new IllegalStateException("Direct reply-to container is not running"); } for (SimpleConsumer consumer : this.consumers) { Channel candidate = consumer.getChannel(); if (candidate.isOpen() && this.inUseConsumerChannels.putIfAbsent(candidate, consumer) == null) { channelHolder = new ChannelHolder(candidate, consumer.incrementAndGetEpoch()); this.whenUsed.put(consumer, System.currentTimeMillis()); break; } } if (channelHolder == null) { this.consumerCount++; super.setConsumersPerQueue(this.consumerCount); } } return channelHolder; } }
/** * Get the channel holder associated with a direct reply-to consumer; contains a * consumer epoch to prevent inappropriate releases. * @return the channel holder. */ public ChannelHolder getChannelHolder() { synchronized (this.consumersMonitor) { ChannelHolder channelHolder = null; while (channelHolder == null) { if (!isRunning()) { throw new IllegalStateException("Direct reply-to container is not running"); } for (SimpleConsumer consumer : this.consumers) { Channel candidate = consumer.getChannel(); if (candidate.isOpen() && this.inUseConsumerChannels.putIfAbsent(candidate, consumer) == null) { channelHolder = new ChannelHolder(candidate, consumer.incrementAndGetEpoch()); this.whenUsed.put(consumer, System.currentTimeMillis()); break; } } if (channelHolder == null) { this.consumerCount++; super.setConsumersPerQueue(this.consumerCount); } } return channelHolder; } }