/** * Release the consumer associated with the channel for reuse. * Set cancelConsumer to true if the client is not prepared to handle/discard a * late arriving reply. * @param channelHolder the channel holder. * @param cancelConsumer true to cancel the consumer. * @param message a message to be included in the cancel event if cancelConsumer is true. */ public void releaseConsumerFor(ChannelHolder channelHolder, boolean cancelConsumer, @Nullable String message) { synchronized (this.consumersMonitor) { SimpleConsumer consumer = this.inUseConsumerChannels.get(channelHolder.getChannel()); if (consumer != null && consumer.getEpoch() == channelHolder.getConsumerEpoch()) { this.inUseConsumerChannels.remove(channelHolder.getChannel()); if (cancelConsumer) { Assert.isTrue(message != null, "A 'message' is required when 'cancelConsumer' is 'true'"); consumer.cancelConsumer("Consumer " + this + " canceled due to " + message); } } } }
/** * Release the consumer associated with the channel for reuse. * Set cancelConsumer to true if the client is not prepared to handle/discard a * late arriving reply. * @param channelHolder the channel holder. * @param cancelConsumer true to cancel the consumer. * @param message a message to be included in the cancel event if cancelConsumer is true. */ public void releaseConsumerFor(ChannelHolder channelHolder, boolean cancelConsumer, @Nullable String message) { synchronized (this.consumersMonitor) { SimpleConsumer consumer = this.inUseConsumerChannels.get(channelHolder.getChannel()); if (consumer != null && consumer.getEpoch() == channelHolder.getConsumerEpoch()) { this.inUseConsumerChannels.remove(channelHolder.getChannel()); if (cancelConsumer) { Assert.isTrue(message != null, "A 'message' is required when 'cancelConsumer' is 'true'"); consumer.cancelConsumer("Consumer " + this + " canceled due to " + message); } } } }