duhengforever commented on a change in pull request #358: [ISSUE #292] Add
support of transactional message feature
URL: https://github.com/apache/rocketmq/pull/358#discussion_r202686351
##########
File path:
broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
##########
@@ -185,4 +191,33 @@ public void unregisterProducer(final String group, final
ClientChannelInfo clien
log.error("", e);
}
}
+
+ public Channel getAvaliableChannel(String groupId) {
+ HashMap<Channel, ClientChannelInfo> channelClientChannelInfoHashMap =
groupChannelTable.get(groupId);
+ List<Channel> channelList = new ArrayList<Channel>();
+ if (channelClientChannelInfoHashMap != null) {
+ for (Channel channel : channelClientChannelInfoHashMap.keySet()) {
+ channelList.add(channel);
+ }
+ int size = channelList.size();
+ if (0 == size) {
+ log.warn("Channel list is empty. groupId={}", groupId);
+ return null;
+ }
+
+ int index = positiveAtomicCounter.incrementAndGet() % size;
+ Channel channel = channelList.get(index);
+ int count = 0;
+ boolean isOk = channel.isActive() && channel.isWritable();
+ while (isOk && count++ < GET_AVALIABLE_CHANNEL_RETRY_COUNT) {
+ index = (++index) % size;
+ channel = channelList.get(index);
+ return channel;
+ }
Review comment:
Thanks for your careful review,and I will fix this problem ASAP.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services