You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/11/18 07:03:41 UTC

[GitHub] [rocketmq] odbozhou commented on a change in pull request #3499: [ISSUE #3498] Make messages in reviveTopic more evenly written to different queues

odbozhou commented on a change in pull request #3499:
URL: https://github.com/apache/rocketmq/pull/3499#discussion_r751955059



##########
File path: broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java
##########
@@ -350,7 +353,7 @@ private RemotingCommand processRequest(final Channel channel, RemotingCommand re
         if (requestHeader.isOrder()) {
             reviveQid = KeyBuilder.POP_ORDER_REVIVE_QUEUE;
         } else {
-            reviveQid = randomQ % this.brokerController.getBrokerConfig().getReviveQueueNum();
+            reviveQid = Math.abs(ckMessageNumber.getAndIncrement() % this.brokerController.getBrokerConfig().getReviveQueueNum());

Review comment:
       Whether the range of AtomicInteger is a bit small, even if there is abs, it may return a negative number, and the message volume may be out of bounds if it is too large. Is AtomicLong or ThreadLocalRandom better?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org