diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandom.java similarity index 85% rename from client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java rename to client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandom.java index 4e9a92d23953f51d37182f64cec66828cbc08651..070fcc3e8169e7425a8d6c87fec75ba2e9070689 100644 --- a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java +++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandom.java @@ -22,17 +22,12 @@ import org.apache.rocketmq.client.producer.MessageQueueSelector; import org.apache.rocketmq.common.message.Message; import org.apache.rocketmq.common.message.MessageQueue; -public class SelectMessageQueueByRandoom implements MessageQueueSelector { +public class SelectMessageQueueByRandom implements MessageQueueSelector { private Random random = new Random(System.currentTimeMillis()); @Override public MessageQueue select(List mqs, Message msg, Object arg) { - int value = random.nextInt(); - if (value < 0) { - value = Math.abs(value); - } - - value = value % mqs.size(); + int value = random.nextInt(mqs.size()); return mqs.get(value); } }