com.alibaba.rocketmq.broker.BrokerController Java Examples

The following examples show how to use com.alibaba.rocketmq.broker.BrokerController. 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: TopicConfigManagerTest.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
@Test
public void test_flushTopicConfig() throws Exception {
    BrokerController brokerController = new BrokerController(//
        new BrokerConfig(), //
        new NettyServerConfig(), //
        new NettyClientConfig(), //
        new MessageStoreConfig());
    boolean initResult = brokerController.initialize();
    System.out.println("initialize " + initResult);
    brokerController.start();

    TopicConfigManager topicConfigManager = new TopicConfigManager(brokerController);

    TopicConfig topicConfig = topicConfigManager.createTopicInSendMessageMethod("TestTopic_SEND",
        MixAll.DEFAULT_TOPIC, null, 4, 0);
    assertTrue(topicConfig != null);

    System.out.println(topicConfig);

    for (int i = 0; i < 10; i++) {
        String topic = "UNITTEST-" + i;
        topicConfig = topicConfigManager.createTopicInSendMessageMethod(topic, MixAll.DEFAULT_TOPIC, null,
            4, 0);
        assertTrue(topicConfig != null);
    }

    topicConfigManager.persist();

    brokerController.shutdown();
}
 
Example #2
Source File: ConsumerOffsetManagerTest.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void test_flushConsumerOffset() throws Exception {
    BrokerController brokerController = new BrokerController(//
        new BrokerConfig(), //
        new NettyServerConfig(), //
        new NettyClientConfig(), //
        new MessageStoreConfig());
    boolean initResult = brokerController.initialize();
    System.out.println("initialize " + initResult);
    brokerController.start();

    ConsumerOffsetManager consumerOffsetManager = new ConsumerOffsetManager(brokerController);

    Random random = new Random();

    for (int i = 0; i < 100; i++) {
        String group = "DIANPU_GROUP_" + i;
        for (int id = 0; id < 16; id++) {
            consumerOffsetManager.commitOffset(group, "TOPIC_A", id,
                random.nextLong() % 1024 * 1024 * 1024);
            consumerOffsetManager.commitOffset(group, "TOPIC_B", id,
                random.nextLong() % 1024 * 1024 * 1024);
            consumerOffsetManager.commitOffset(group, "TOPIC_C", id,
                random.nextLong() % 1024 * 1024 * 1024);
        }
    }

    consumerOffsetManager.persist();

    brokerController.shutdown();
}
 
Example #3
Source File: TopicConfigManagerTest.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void test_flushTopicConfig() throws Exception {
    BrokerController brokerController = new BrokerController(//
        new BrokerConfig(), //
        new NettyServerConfig(), //
        new NettyClientConfig(), //
        new MessageStoreConfig());
    boolean initResult = brokerController.initialize();
    System.out.println("initialize " + initResult);
    brokerController.start();

    TopicConfigManager topicConfigManager = new TopicConfigManager(brokerController);

    TopicConfig topicConfig =
            topicConfigManager.createTopicInSendMessageMethod("TestTopic_SEND", MixAll.DEFAULT_TOPIC,
                null, 4, 0);
    assertTrue(topicConfig != null);

    System.out.println(topicConfig);

    for (int i = 0; i < 10; i++) {
        String topic = "UNITTEST-" + i;
        topicConfig =
                topicConfigManager
                    .createTopicInSendMessageMethod(topic, MixAll.DEFAULT_TOPIC, null, 4, 0);
        assertTrue(topicConfig != null);
    }

    topicConfigManager.persist();

    brokerController.shutdown();
}
 
Example #4
Source File: TopicConfigManagerTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void test_flushTopicConfig() throws Exception {
    BrokerController brokerController = new BrokerController(//
            new BrokerConfig(), //
            new NettyServerConfig(), //
            new NettyClientConfig(), //
            new MessageStoreConfig());
    boolean initResult = brokerController.initialize();
    System.out.println("initialize " + initResult);
    brokerController.start();

    TopicConfigManager topicConfigManager = new TopicConfigManager(brokerController);

    TopicConfig topicConfig =
            topicConfigManager.createTopicInSendMessageMethod("TestTopic_SEND", MixAll.DEFAULT_TOPIC,
                    null, 4, 0);
    assertTrue(topicConfig != null);

    System.out.println(topicConfig);

    for (int i = 0; i < 10; i++) {
        String topic = "UNITTEST-" + i;
        topicConfig =
                topicConfigManager
                        .createTopicInSendMessageMethod(topic, MixAll.DEFAULT_TOPIC, null, 4, 0);
        assertTrue(topicConfig != null);
    }

    topicConfigManager.persist();

    brokerController.shutdown();
}
 
Example #5
Source File: ConsumerOffsetManagerTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void test_flushConsumerOffset() throws Exception {
    BrokerController brokerController = new BrokerController(//
            new BrokerConfig(), //
            new NettyServerConfig(), //
            new NettyClientConfig(), //
            new MessageStoreConfig());
    boolean initResult = brokerController.initialize();
    System.out.println("initialize " + initResult);
    brokerController.start();

    ConsumerOffsetManager consumerOffsetManager = new ConsumerOffsetManager(brokerController);

    Random random = new Random();

    for (int i = 0; i < 100; i++) {
        String group = "DIANPU_GROUP_" + i;
        for (int id = 0; id < 16; id++) {
            consumerOffsetManager.commitOffset(null, group, "TOPIC_A", id,
                    random.nextLong() % 1024 * 1024 * 1024);
            consumerOffsetManager.commitOffset(null, group, "TOPIC_B", id,
                    random.nextLong() % 1024 * 1024 * 1024);
            consumerOffsetManager.commitOffset(null, group, "TOPIC_C", id,
                    random.nextLong() % 1024 * 1024 * 1024);
        }
    }

    consumerOffsetManager.persist();

    brokerController.shutdown();
}
 
Example #6
Source File: ConsumerOffsetManagerTest.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
@Test
public void test_flushConsumerOffset() throws Exception {
    BrokerController brokerController = new BrokerController(//
        new BrokerConfig(), //
        new NettyServerConfig(), //
        new NettyClientConfig(), //
        new MessageStoreConfig());
    boolean initResult = brokerController.initialize();
    System.out.println("initialize " + initResult);
    brokerController.start();

    ConsumerOffsetManager consumerOffsetManager = new ConsumerOffsetManager(brokerController);

    Random random = new Random();

    for (int i = 0; i < 100; i++) {
        String group = "DIANPU_GROUP_" + i;
        for (int id = 0; id < 16; id++) {
            consumerOffsetManager.commitOffset(group, "TOPIC_A", id,
                random.nextLong() % 1024 * 1024 * 1024);
            consumerOffsetManager.commitOffset(group, "TOPIC_B", id,
                random.nextLong() % 1024 * 1024 * 1024);
            consumerOffsetManager.commitOffset(group, "TOPIC_C", id,
                random.nextLong() % 1024 * 1024 * 1024);
        }
    }

    consumerOffsetManager.persist();

    brokerController.shutdown();
}
 
Example #7
Source File: DefaultConsumerIdsChangeListener.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public DefaultConsumerIdsChangeListener(BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #8
Source File: Broker2Client.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public Broker2Client(BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #9
Source File: ClientHousekeepingService.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public ClientHousekeepingService(final BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #10
Source File: BrokerFastFailure.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public BrokerFastFailure(final BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #11
Source File: PullRequestHoldService.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public PullRequestHoldService(final BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #12
Source File: SendMessageTest.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Test
public void test_sendMessage() throws Exception {
    BrokerController brokerController = new BrokerController(//
            new BrokerConfig(), //
            new NettyServerConfig(), //
            new NettyClientConfig(), //
            new MessageStoreConfig());
    boolean initResult = brokerController.initialize();
    System.out.println("initialize " + initResult);

    brokerController.start();

    MQClientAPIImpl client = new MQClientAPIImpl(new NettyClientConfig(), null, null, null);
    client.start();

    for (int i = 0; i < 100000; i++) {
        String topic = "UnitTestTopic_" + i % 3;
        Message msg = new Message(topic, "TAG1 TAG2", "100200300", ("Hello, Nice world\t" + i).getBytes());
        msg.setDelayTimeLevel(i % 3 + 1);

        try {
            SendMessageRequestHeader requestHeader = new SendMessageRequestHeader();
            requestHeader.setProducerGroup("abc");
            requestHeader.setTopic(msg.getTopic());
            requestHeader.setDefaultTopic(MixAll.DEFAULT_TOPIC);
            requestHeader.setDefaultTopicQueueNums(4);
            requestHeader.setQueueId(i % 4);
            requestHeader.setSysFlag(0);
            requestHeader.setBornTimestamp(System.currentTimeMillis());
            requestHeader.setFlag(msg.getFlag());
            requestHeader.setProperties(MessageDecoder.messageProperties2String(msg.getProperties()));

            SendResult result = client.sendMessage("127.0.0.1:10911", "brokerName", msg, requestHeader, 1000 * 5,
                    CommunicationMode.SYNC, new SendMessageContext(), null);
            System.out.println(i + "\t" + result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    client.shutdown();

    brokerController.shutdown();
}
 
Example #13
Source File: SubscriptionGroupManager.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public SubscriptionGroupManager(BrokerController brokerController) {
    this.brokerController = brokerController;
    this.init();
}
 
Example #14
Source File: ConsumerOffsetManager.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public ConsumerOffsetManager(BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #15
Source File: SlaveSynchronize.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public SlaveSynchronize(BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #16
Source File: SendMessageProcessor.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public SendMessageProcessor(final BrokerController brokerController) {
    super(brokerController);
}
 
Example #17
Source File: FilterServerManager.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public FilterServerManager(final BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #18
Source File: QueryMessageProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public QueryMessageProcessor(final BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #19
Source File: EndTransactionProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public EndTransactionProcessor(final BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #20
Source File: PullMessageProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public PullMessageProcessor(final BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #21
Source File: AdminBrokerProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public AdminBrokerProcessor(final BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #22
Source File: ClientManageProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public ClientManageProcessor(final BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #23
Source File: AbstractSendMessageProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public AbstractSendMessageProcessor(final BrokerController brokerController) {
    this.brokerController = brokerController;
    this.storeHost = new InetSocketAddress(brokerController.getBrokerConfig().getBrokerIP1(),
        brokerController.getNettyServerConfig().getListenPort());
}
 
Example #24
Source File: SendMessageProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public SendMessageProcessor(final BrokerController brokerController) {
    super(brokerController);
}
 
Example #25
Source File: ForwardRequestProcessor.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public ForwardRequestProcessor(final BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #26
Source File: FilterServerManager.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public FilterServerManager(final BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #27
Source File: PullRequestHoldService.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public PullRequestHoldService(final BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #28
Source File: DefaultConsumerIdsChangeListener.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public DefaultConsumerIdsChangeListener(BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #29
Source File: Broker2Client.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public Broker2Client(BrokerController brokerController) {
    this.brokerController = brokerController;
}
 
Example #30
Source File: ClientHousekeepingService.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public ClientHousekeepingService(final BrokerController brokerController) {
    this.brokerController = brokerController;
}