diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java index 28d103c0bfcf50c082a3deea68096a6f6d6b04fc..61ceae53860d16d87045b1af067650f8529424fb 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java @@ -209,10 +209,13 @@ public class ProducerManager { Channel channel = channelList.get(index); int count = 0; boolean isOk = channel.isActive() && channel.isWritable(); - while (isOk && count++ < GET_AVALIABLE_CHANNEL_RETRY_COUNT) { + while (count++ < GET_AVALIABLE_CHANNEL_RETRY_COUNT) { + if (isOk) { + return channel; + } index = (++index) % size; channel = channelList.get(index); - return channel; + isOk = channel.isActive() && channel.isWritable(); } } else { log.warn("Check transaction failed, channel table is empty. groupId={}", groupId);