Search in sources :

Example 1 with PullConsumerCluter

use of cn.tellwhy.third.rocket.PullConsumerCluter in project warn-report by saaavsaaa.

the class TestRocketCluter method TestCatch.

@Test
public void TestCatch() throws MQClientException, RemotingException, InterruptedException, MQBrokerException {
    // 336
    // "192.168.1.45:9876";
    final String address = "192.168.1.44:9876";
    final String topic = "registerTopic";
    final String consumerGroup = "cgr1";
    final String subExpression = "*";
    final Long offset = 0L;
    List<String> addresses = new ArrayList<String>();
    addresses.add("192.168.1.44:9876");
    addresses.add("192.168.1.45:9876");
    PullConsumerCluter consumer = new PullConsumerCluter(address, consumerGroup);
    List<MessageExt> extList = consumer.getMessage(topic, offset, subExpression);
    for (MessageExt ext : extList) {
        String key = ext.getKeys();
        String keys = ext.getProperty("KEYS");
        String value = new String(ext.getBody());
        System.out.println("key : " + key + "; KEYS :" + keys + "; body : " + value + "\n");
    }
}
Also used : MessageExt(com.alibaba.rocketmq.common.message.MessageExt) ArrayList(java.util.ArrayList) PullConsumerCluter(cn.tellwhy.third.rocket.PullConsumerCluter) Test(org.junit.Test)

Aggregations

PullConsumerCluter (cn.tellwhy.third.rocket.PullConsumerCluter)1 MessageExt (com.alibaba.rocketmq.common.message.MessageExt)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1