Search in sources :

Example 1 with TopicConfig

use of org.apache.rocketmq.common.TopicConfig in project ignite by apache.

the class RocketMQStreamerTest method initTopic.

/**
 * Initializes RocketMQ topic.
 *
 * @param topic Topic.
 * @param nsAddr Nameserver address.
 * @throws IgniteInterruptedCheckedException If fails.
 */
private void initTopic(String topic, String nsAddr) throws Exception {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt();
    defaultMQAdminExt.setNamesrvAddr(nsAddr);
    try {
        defaultMQAdminExt.start();
        TopicConfig topicConfig = new TopicConfig();
        topicConfig.setTopicName(topic);
        topicConfig.setReadQueueNums(4);
        topicConfig.setWriteQueueNums(4);
        defaultMQAdminExt.createAndUpdateTopicConfig(testRocketMQServer.getBrokerAddr(), topicConfig);
        U.sleep(100);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
Also used : DefaultMQAdminExt(org.apache.rocketmq.tools.admin.DefaultMQAdminExt) TopicConfig(org.apache.rocketmq.common.TopicConfig)

Example 2 with TopicConfig

use of org.apache.rocketmq.common.TopicConfig in project rocketmq-externals by apache.

the class TopicServiceImpl method examineTopicConfig.

@Override
public List<TopicConfigInfo> examineTopicConfig(String topic) {
    List<TopicConfigInfo> topicConfigInfoList = Lists.newArrayList();
    TopicRouteData topicRouteData = route(topic);
    for (BrokerData brokerData : topicRouteData.getBrokerDatas()) {
        TopicConfigInfo topicConfigInfo = new TopicConfigInfo();
        TopicConfig topicConfig = examineTopicConfig(topic, brokerData.getBrokerName());
        BeanUtils.copyProperties(topicConfig, topicConfigInfo);
        topicConfigInfo.setBrokerNameList(Lists.newArrayList(brokerData.getBrokerName()));
        topicConfigInfoList.add(topicConfigInfo);
    }
    return topicConfigInfoList;
}
Also used : BrokerData(org.apache.rocketmq.common.protocol.route.BrokerData) TopicConfigInfo(org.apache.rocketmq.console.model.request.TopicConfigInfo) TopicConfig(org.apache.rocketmq.common.TopicConfig) TopicRouteData(org.apache.rocketmq.common.protocol.route.TopicRouteData)

Example 3 with TopicConfig

use of org.apache.rocketmq.common.TopicConfig in project rocketmq-externals by apache.

the class TopicServiceImplTest method examineTopicConfigList.

@Test
public void examineTopicConfigList() throws Exception {
    TopicConfig topicConfig = topicService.examineTopicConfig(TEST_CONSOLE_TOPIC, TestConstant.TEST_BROKER_NAME);
    Assert.assertNotNull(topicConfig);
    Assert.assertEquals(topicConfig.getReadQueueNums(), READ_QUEUE_NUM);
    Assert.assertEquals(topicConfig.getWriteQueueNums(), WRITE_QUEUE_NUM);
}
Also used : TopicConfig(org.apache.rocketmq.common.TopicConfig) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with TopicConfig

use of org.apache.rocketmq.common.TopicConfig in project rocketmq-externals by apache.

the class TopicServiceImpl method createOrUpdate.

@Override
public void createOrUpdate(TopicConfigInfo topicCreateOrUpdateRequest) {
    TopicConfig topicConfig = new TopicConfig();
    BeanUtils.copyProperties(topicCreateOrUpdateRequest, topicConfig);
    try {
        ClusterInfo clusterInfo = mqAdminExt.examineBrokerClusterInfo();
        for (String brokerName : changeToBrokerNameSet(clusterInfo.getClusterAddrTable(), topicCreateOrUpdateRequest.getClusterNameList(), topicCreateOrUpdateRequest.getBrokerNameList())) {
            mqAdminExt.createAndUpdateTopicConfig(clusterInfo.getBrokerAddrTable().get(brokerName).selectBrokerAddr(), topicConfig);
        }
    } catch (Exception err) {
        throw Throwables.propagate(err);
    }
}
Also used : ClusterInfo(org.apache.rocketmq.common.protocol.body.ClusterInfo) TopicConfig(org.apache.rocketmq.common.TopicConfig)

Example 5 with TopicConfig

use of org.apache.rocketmq.common.TopicConfig in project rocketmq-externals by apache.

the class IntegrationTestBase method createTopic.

public static void createTopic(String topic, String addr) {
    TopicConfig topicConfig = new TopicConfig();
    topicConfig.setTopicName(topic);
    topicConfig.setReadQueueNums(4);
    topicConfig.setWriteQueueNums(4);
    try {
        defaultMQAdminExt.createAndUpdateTopicConfig(addr, topicConfig);
    } catch (Exception e) {
        logger.error("Create topic:{} addr:{} failed", addr, topic);
    }
}
Also used : TopicConfig(org.apache.rocketmq.common.TopicConfig) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Aggregations

TopicConfig (org.apache.rocketmq.common.TopicConfig)5 MQClientException (org.apache.rocketmq.client.exception.MQClientException)1 ClusterInfo (org.apache.rocketmq.common.protocol.body.ClusterInfo)1 BrokerData (org.apache.rocketmq.common.protocol.route.BrokerData)1 TopicRouteData (org.apache.rocketmq.common.protocol.route.TopicRouteData)1 TopicConfigInfo (org.apache.rocketmq.console.model.request.TopicConfigInfo)1 DefaultMQAdminExt (org.apache.rocketmq.tools.admin.DefaultMQAdminExt)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1