vongosling 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_r201624161
##########
File path:
broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
##########
@@ -185,4 +190,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++ < 3) {
Review comment:
3 is a magic number
----------------------------------------------------------------
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