Search in sources :

Example 6 with TopicPublishInfo

use of org.apache.rocketmq.client.impl.producer.TopicPublishInfo in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class MQClientInstanceTest method testTopicRouteData2TopicPublishInfo.

@Test
public void testTopicRouteData2TopicPublishInfo() {
    TopicRouteData topicRouteData = new TopicRouteData();
    topicRouteData.setFilterServerTable(new HashMap<String, List<String>>());
    List<BrokerData> brokerDataList = new ArrayList<BrokerData>();
    BrokerData brokerData = new BrokerData();
    brokerData.setBrokerName("BrokerA");
    brokerData.setCluster("DefaultCluster");
    HashMap<Long, String> brokerAddrs = new HashMap<Long, String>();
    brokerAddrs.put(0L, "127.0.0.1:10911");
    brokerData.setBrokerAddrs(brokerAddrs);
    brokerDataList.add(brokerData);
    topicRouteData.setBrokerDatas(brokerDataList);
    List<QueueData> queueDataList = new ArrayList<QueueData>();
    QueueData queueData = new QueueData();
    queueData.setBrokerName("BrokerA");
    queueData.setPerm(6);
    queueData.setReadQueueNums(3);
    queueData.setWriteQueueNums(4);
    queueData.setTopicSynFlag(0);
    queueDataList.add(queueData);
    topicRouteData.setQueueDatas(queueDataList);
    TopicPublishInfo topicPublishInfo = MQClientInstance.topicRouteData2TopicPublishInfo(topic, topicRouteData);
    assertThat(topicPublishInfo.isHaveTopicRouterInfo()).isFalse();
    assertThat(topicPublishInfo.getMessageQueueList().size()).isEqualTo(4);
}
Also used : BrokerData(org.apache.rocketmq.common.protocol.route.BrokerData) HashMap(java.util.HashMap) QueueData(org.apache.rocketmq.common.protocol.route.QueueData) ArrayList(java.util.ArrayList) TopicRouteData(org.apache.rocketmq.common.protocol.route.TopicRouteData) TopicPublishInfo(org.apache.rocketmq.client.impl.producer.TopicPublishInfo) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

TopicPublishInfo (org.apache.rocketmq.client.impl.producer.TopicPublishInfo)6 BrokerData (org.apache.rocketmq.common.protocol.route.BrokerData)6 QueueData (org.apache.rocketmq.common.protocol.route.QueueData)6 TopicRouteData (org.apache.rocketmq.common.protocol.route.TopicRouteData)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2 MQClientException (org.apache.rocketmq.client.exception.MQClientException)2 MQConsumerInner (org.apache.rocketmq.client.impl.consumer.MQConsumerInner)2 MQProducerInner (org.apache.rocketmq.client.impl.producer.MQProducerInner)2 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)2 RemotingException (org.apache.rocketmq.remoting.exception.RemotingException)2 Test (org.junit.Test)2