org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely Java Examples

The following examples show how to use org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RebalancePushImplTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testMessageQueueChanged_CountThreshold() {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    // Just set pullThresholdForQueue
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(1024);

    // Set pullThresholdForTopic
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(512);

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(341);
}
 
Example #2
Source File: RebalancePushImplTest.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Test
public void testMessageQueueChanged_CountThreshold() {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    // Just set pullThresholdForQueue
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(1024);

    // Set pullThresholdForTopic
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(512);

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(341);
}
 
Example #3
Source File: RebalancePushImplTest.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Test
public void testMessageQueueChanged_SizeThreshold() {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    // Just set pullThresholdSizeForQueue
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(1024);

    // Set pullThresholdSizeForTopic
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(512);

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(341);
}
 
Example #4
Source File: RocketMQCanalConnector.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
public void connect() throws CanalClientException {

        RPCHook rpcHook = null;
        if (null != accessKey && accessKey.length() > 0 && null != secretKey && secretKey.length() > 0) {
            SessionCredentials sessionCredentials = new SessionCredentials();
            sessionCredentials.setAccessKey(accessKey);
            sessionCredentials.setSecretKey(secretKey);
            rpcHook = new ClientRPCHook(sessionCredentials);
        }
        rocketMQConsumer = new DefaultMQPushConsumer(groupName, rpcHook, new AllocateMessageQueueAveragely());
        rocketMQConsumer.setVipChannelEnabled(false);
        if (!StringUtils.isBlank(nameServer)) {
            rocketMQConsumer.setNamesrvAddr(nameServer);
        }
        if (batchSize != -1) {
            rocketMQConsumer.setConsumeMessageBatchMaxSize(batchSize);
        }
    }
 
Example #5
Source File: RebalancePushImplTest.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Test
public void testMessageQueueChanged_SizeThreshold() {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    // Just set pullThresholdSizeForQueue
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(1024);

    // Set pullThresholdSizeForTopic
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(512);

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(341);
}
 
Example #6
Source File: RebalancePushImplTest.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Test
public void testMessageQueueChanged_CountThreshold() {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    // Just set pullThresholdForQueue
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(1024);

    // Set pullThresholdForTopic
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(512);

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(341);
}
 
Example #7
Source File: AclClient.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public static void pushConsumer() throws MQClientException {

        DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name_5", getAclRPCHook(), new AllocateMessageQueueAveragely());
        consumer.setNamesrvAddr("127.0.0.1:9876");
        consumer.subscribe("TopicTest", "*");
        consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
        // Wrong time format 2017_0422_221800
        consumer.setConsumeTimestamp("20180422221800");
        consumer.registerMessageListener(new MessageListenerConcurrently() {

            @Override
            public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
                System.out.printf("%s Receive New Messages: %s %n", Thread.currentThread().getName(), msgs);
                printBody(msgs);
                return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
            }
        });
        consumer.start();
        System.out.printf("Consumer Started.%n");
    }
 
Example #8
Source File: RebalancePushImplTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testMessageQueueChanged_CountThreshold() {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    // Just set pullThresholdForQueue
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(1024);

    // Set pullThresholdForTopic
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(512);

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(341);
}
 
Example #9
Source File: RebalancePushImplTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testMessageQueueChanged_SizeThreshold() {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    // Just set pullThresholdSizeForQueue
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(1024);

    // Set pullThresholdSizeForTopic
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(512);

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(341);
}
 
Example #10
Source File: RebalancePushImplTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testMessageQueueChanged_CountThreshold() {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    // Just set pullThresholdForQueue
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(1024);

    // Set pullThresholdForTopic
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(512);

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdForQueue()).isEqualTo(341);
}
 
Example #11
Source File: RebalancePushImplTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testMessageQueueChanged_SizeThreshold() {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    // Just set pullThresholdSizeForQueue
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(1024);

    // Set pullThresholdSizeForTopic
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(512);

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(341);
}
 
Example #12
Source File: RebalancePushImplTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testMessageQueueChanged_SizeThreshold() {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    // Just set pullThresholdSizeForQueue
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(1024);

    // Set pullThresholdSizeForTopic
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(512);

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.getDefaultMQPushConsumer().getPullThresholdSizeForQueue()).isEqualTo(341);
}
 
Example #13
Source File: AllocateMQSubCommand.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
    adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        adminExt.start();

        String topic = commandLine.getOptionValue('t').trim();
        String ips = commandLine.getOptionValue('i').trim();
        final String[] split = ips.split(",");
        final List<String> ipList = new LinkedList<String>();
        for (String ip : split) {
            ipList.add(ip);
        }

        final TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topic);
        final Set<MessageQueue> mqs = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);

        final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely();

        RebalanceResult rr = new RebalanceResult();

        for (String i : ipList) {
            final List<MessageQueue> mqResult = averagely.allocate("aa", i, new ArrayList<MessageQueue>(mqs), ipList);
            rr.getResult().put(i, mqResult);
        }

        final String json = RemotingSerializable.toJson(rr, false);
        System.out.printf("%s%n", json);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        adminExt.shutdown();
    }
}
 
Example #14
Source File: RebalancePushImplTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testMessageQueueChanged_ConsumerRuntimeInfo() throws MQClientException {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForQueue(1024);
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);

    defaultMQPushConsumer.setConsumeMessageService(new ConsumeMessageConcurrentlyService(defaultMQPushConsumer, null));
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("-1");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("-1");

    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForTopic(1024);
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("512");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("512");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("1024");

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("341");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("341");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("1024");
}
 
Example #15
Source File: SecKillChargeOrderConsumer.java    From seckill-rocketmq with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void init() {
    defaultMQPushConsumer =
            new DefaultMQPushConsumer(
                MessageProtocolConst.SECKILL_CHARGE_ORDER_TOPIC.getConsumerGroup(),
                    new AclClientRPCHook(new SessionCredentials(aclAccessKey, aclAccessSecret)),
                    // 平均分配队列算法,hash
                    new AllocateMessageQueueAveragely());
    defaultMQPushConsumer.setNamesrvAddr(namesrvConfig.nameSrvAddr());
    // 从头开始消费
    defaultMQPushConsumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
    // 消费模式:集群模式
    // 集群:同一条消息 只会被一个消费者节点消费到
    // 广播:同一条消息 每个消费者都会消费到
    defaultMQPushConsumer.setMessageModel(MessageModel.CLUSTERING);
    // 注册监听器
    defaultMQPushConsumer.registerMessageListener(messageListener);
    // 设置每次拉取的消息量,默认为1
    defaultMQPushConsumer.setConsumeMessageBatchMaxSize(1);
    // 订阅所有消息
    try {
        defaultMQPushConsumer.subscribe(MessageProtocolConst.SECKILL_CHARGE_ORDER_TOPIC.getTopic(), "*");
        // 启动消费者
        defaultMQPushConsumer.start();
    } catch (MQClientException e) {
        LOGGER.error("[秒杀下单消费者]--SecKillChargeOrderConsumer加载异常!e={}", LogExceptionWapper.getStackTrace(e));
        throw new RuntimeException("[秒杀下单消费者]--SecKillChargeOrderConsumer加载异常!", e);
    }
    LOGGER.info("[秒杀下单消费者]--SecKillChargeOrderConsumer加载完成!");
}
 
Example #16
Source File: AllocateMQSubCommand.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
    adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        adminExt.start();

        String topic = commandLine.getOptionValue('t').trim();
        String ips = commandLine.getOptionValue('i').trim();
        final String[] split = ips.split(",");
        final List<String> ipList = new LinkedList<String>();
        for (String ip : split) {
            ipList.add(ip);
        }

        final TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topic);
        final Set<MessageQueue> mqs = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);

        final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely();

        RebalanceResult rr = new RebalanceResult();

        for (String i : ipList) {
            final List<MessageQueue> mqResult = averagely.allocate("aa", i, new ArrayList<MessageQueue>(mqs), ipList);
            rr.getResult().put(i, mqResult);
        }

        final String json = RemotingSerializable.toJson(rr, false);
        System.out.printf("%s%n", json);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        adminExt.shutdown();
    }
}
 
Example #17
Source File: AllocateMQSubCommand.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
    adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        adminExt.start();

        String topic = commandLine.getOptionValue('t').trim();
        String ips = commandLine.getOptionValue('i').trim();
        final String[] split = ips.split(",");
        final List<String> ipList = new LinkedList<String>();
        for (String ip : split) {
            ipList.add(ip);
        }

        final TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topic);
        final Set<MessageQueue> mqs = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);

        final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely();

        RebalanceResult rr = new RebalanceResult();

        for (String i : ipList) {
            final List<MessageQueue> mqResult = averagely.allocate("aa", i, new ArrayList<MessageQueue>(mqs), ipList);
            rr.getResult().put(i, mqResult);
        }

        final String json = RemotingSerializable.toJson(rr, false);
        System.out.printf("%s%n", json);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        adminExt.shutdown();
    }
}
 
Example #18
Source File: RebalancePushImplTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Test
public void testMessageQueueChanged_ConsumerRuntimeInfo() throws MQClientException {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForQueue(1024);
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);

    defaultMQPushConsumer.setConsumeMessageService(new ConsumeMessageConcurrentlyService(defaultMQPushConsumer, null));
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("-1");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("-1");

    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForTopic(1024);
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("512");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("512");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("1024");

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("341");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("341");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("1024");
}
 
Example #19
Source File: AllocateMQSubCommand.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
    adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        adminExt.start();

        String topic = commandLine.getOptionValue('t').trim();
        String ips = commandLine.getOptionValue('i').trim();
        final String[] split = ips.split(",");
        final List<String> ipList = new LinkedList<String>();
        for (String ip : split) {
            ipList.add(ip);
        }

        final TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topic);
        final Set<MessageQueue> mqs = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);

        final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely();

        RebalanceResult rr = new RebalanceResult();

        for (String i : ipList) {
            final List<MessageQueue> mqResult = averagely.allocate("aa", i, new ArrayList<MessageQueue>(mqs), ipList);
            rr.getResult().put(i, mqResult);
        }

        final String json = RemotingSerializable.toJson(rr, false);
        System.out.printf("%s%n", json);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        adminExt.shutdown();
    }
}
 
Example #20
Source File: AllocateMQSubCommand.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
    adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        adminExt.start();

        String topic = commandLine.getOptionValue('t').trim();
        String ips = commandLine.getOptionValue('i').trim();
        final String[] split = ips.split(",");
        final List<String> ipList = new LinkedList<String>();
        for (String ip : split) {
            ipList.add(ip);
        }

        final TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topic);
        final Set<MessageQueue> mqs = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);

        final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely();

        RebalanceResult rr = new RebalanceResult();

        for (String i : ipList) {
            final List<MessageQueue> mqResult = averagely.allocate("aa", i, new ArrayList<MessageQueue>(mqs), ipList);
            rr.getResult().put(i, mqResult);
        }

        final String json = RemotingSerializable.toJson(rr, false);
        System.out.printf("%s%n", json);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        adminExt.shutdown();
    }
}
 
Example #21
Source File: AllocateMQSubCommand.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
    adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        adminExt.start();

        String topic = commandLine.getOptionValue('t').trim();
        String ips = commandLine.getOptionValue('i').trim();
        final String[] split = ips.split(",");
        final List<String> ipList = new LinkedList<String>();
        for (String ip : split) {
            ipList.add(ip);
        }

        final TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topic);
        final Set<MessageQueue> mqs = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);

        final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely();

        RebalanceResult rr = new RebalanceResult();

        for (String i : ipList) {
            final List<MessageQueue> mqResult = averagely.allocate("aa", i, new ArrayList<MessageQueue>(mqs), ipList);
            rr.getResult().put(i, mqResult);
        }

        final String json = RemotingSerializable.toJson(rr, false);
        System.out.printf("%s%n", json);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        adminExt.shutdown();
    }
}
 
Example #22
Source File: RebalancePushImplTest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testMessageQueueChanged_ConsumerRuntimeInfo() throws MQClientException {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForQueue(1024);
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);

    defaultMQPushConsumer.setConsumeMessageService(new ConsumeMessageConcurrentlyService(defaultMQPushConsumer, null));
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("-1");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("-1");

    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForTopic(1024);
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("512");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("512");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("1024");

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("341");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("341");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("1024");
}
 
Example #23
Source File: AllocateMQSubCommand.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
    adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        adminExt.start();

        String topic = commandLine.getOptionValue('t').trim();
        String ips = commandLine.getOptionValue('i').trim();
        final String[] split = ips.split(",");
        final List<String> ipList = new LinkedList<String>();
        for (String ip : split) {
            ipList.add(ip);
        }

        final TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topic);
        final Set<MessageQueue> mqs = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);

        final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely();

        RebalanceResult rr = new RebalanceResult();

        for (String i : ipList) {
            final List<MessageQueue> mqResult = averagely.allocate("aa", i, new ArrayList<MessageQueue>(mqs), ipList);
            rr.getResult().put(i, mqResult);
        }

        final String json = RemotingSerializable.toJson(rr, false);
        System.out.printf("%s%n", json);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        adminExt.shutdown();
    }
}
 
Example #24
Source File: RebalancePushImplTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testMessageQueueChanged_ConsumerRuntimeInfo() throws MQClientException {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForQueue(1024);
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);

    defaultMQPushConsumer.setConsumeMessageService(new ConsumeMessageConcurrentlyService(defaultMQPushConsumer, null));
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("-1");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("-1");

    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForTopic(1024);
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("512");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("512");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("1024");

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("341");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("341");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("1024");
}
 
Example #25
Source File: RebalancePushImplTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testMessageQueueChanged_ConsumerRuntimeInfo() throws MQClientException {
    RebalancePushImpl rebalancePush = new RebalancePushImpl(consumerGroup, MessageModel.CLUSTERING,
        new AllocateMessageQueueAveragely(), mqClientInstance, defaultMQPushConsumer);
    init(rebalancePush);

    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForQueue(1024);
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForQueue(1024);
    Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 0));
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 1));
    doRebalanceForcibly(rebalancePush, allocateResultSet);

    defaultMQPushConsumer.setConsumeMessageService(new ConsumeMessageConcurrentlyService(defaultMQPushConsumer, null));
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("-1");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("-1");

    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdSizeForTopic(1024);
    defaultMQPushConsumer.getDefaultMQPushConsumer().setPullThresholdForTopic(1024);
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("512");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("512");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("1024");

    // Change message queue allocate result
    allocateResultSet.add(new MessageQueue(topic, "BrokerA", 2));
    doRebalanceForcibly(rebalancePush, allocateResultSet);
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForQueue")).isEqualTo("341");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForQueue")).isEqualTo("341");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdSizeForTopic")).isEqualTo("1024");
    assertThat(defaultMQPushConsumer.consumerRunningInfo().getProperties().get("pullThresholdForTopic")).isEqualTo("1024");
}
 
Example #26
Source File: AllocateMQSubCommand.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
    adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        adminExt.start();

        String topic = commandLine.getOptionValue('t').trim();
        String ips = commandLine.getOptionValue('i').trim();
        final String[] split = ips.split(",");
        final List<String> ipList = new LinkedList<String>();
        for (String ip : split) {
            ipList.add(ip);
        }

        final TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topic);
        final Set<MessageQueue> mqs = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);

        final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely();

        RebalanceResult rr = new RebalanceResult();

        for (String i : ipList) {
            final List<MessageQueue> mqResult = averagely.allocate("aa", i, new ArrayList<MessageQueue>(mqs), ipList);
            rr.getResult().put(i, mqResult);
        }

        final String json = RemotingSerializable.toJson(rr, false);
        System.out.printf("%s%n", json);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        adminExt.shutdown();
    }
}
 
Example #27
Source File: DefaultMQPushConsumer.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
/**
 * Default constructor.
 */
public DefaultMQPushConsumer() {
    this(MixAll.DEFAULT_CONSUMER_GROUP, null, new AllocateMessageQueueAveragely());
}
 
Example #28
Source File: DefaultMQPushConsumer.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
/**
 * Default constructor.
 */
public DefaultMQPushConsumer() {
    this(MixAll.DEFAULT_CONSUMER_GROUP, null, new AllocateMessageQueueAveragely());
}
 
Example #29
Source File: DefaultMQPushConsumer.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
/**
 * Default constructor.
 */
public DefaultMQPushConsumer() {
    this(MixAll.DEFAULT_CONSUMER_GROUP, null, new AllocateMessageQueueAveragely());
}
 
Example #30
Source File: DefaultMQPushConsumer.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
/**
 * Default constructor.
 */
public DefaultMQPushConsumer() {
    this(null, MixAll.DEFAULT_CONSUMER_GROUP, null, new AllocateMessageQueueAveragely());
}