提交 e1a42e4e 编写于 作者: 释一 提交者: yukon

Fix random int bug in SelectMessageQueueByRandom

Author: 释一 <quanwei.lqw@alibaba-inc.com>

Closes #173 from swwlqw/master.
上级 81884c8d
......@@ -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<MessageQueue> 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);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册