Java Code Examples for com.alibaba.rocketmq.common.message.MessageQueue#getTopic()

The following examples show how to use com.alibaba.rocketmq.common.message.MessageQueue#getTopic() . 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: ConsumerServiceImpl.java    From rocket-console with Apache License 2.0 6 votes vote down vote up
@Override
public List<TopicConsumerInfo> queryConsumeStatsList(final String topic, String groupName) {
    ConsumeStats consumeStats = null;
    try {
        consumeStats = mqAdminExt.examineConsumeStats(groupName); // todo  ConsumeStats examineConsumeStats(final String consumerGroup, final String topic) can use
    } catch (Exception e) {
        throw propagate(e);
    }
    List<MessageQueue> mqList = Lists.newArrayList(Iterables.filter(consumeStats.getOffsetTable().keySet(), new Predicate<MessageQueue>() {
        @Override
        public boolean apply(MessageQueue o) {
            return StringUtils.isBlank(topic) || o.getTopic().equals(topic);
        }
    }));
    Collections.sort(mqList);
    List<TopicConsumerInfo> topicConsumerInfoList = Lists.newArrayList();
    TopicConsumerInfo nowTopicConsumerInfo = null;
    for (MessageQueue mq : mqList) {
        if (nowTopicConsumerInfo == null || (!StringUtils.equals(mq.getTopic(), nowTopicConsumerInfo.getTopic()))) {
            nowTopicConsumerInfo = new TopicConsumerInfo(mq.getTopic());
            topicConsumerInfoList.add(nowTopicConsumerInfo);
        }
        nowTopicConsumerInfo.appendQueueStatInfo(QueueStatInfo.fromOffsetTableEntry(mq, consumeStats.getOffsetTable().get(mq)));
    }
    return topicConsumerInfoList;
}
 
Example 2
Source File: Broker2Client.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
private List<MessageQueueForC> convertOffsetTable2OffsetList(Map<MessageQueue, Long> table) {
    List<MessageQueueForC> list = new ArrayList<MessageQueueForC>();
    for (Entry<MessageQueue, Long> entry : table.entrySet()) {
        MessageQueue mq = entry.getKey();
        MessageQueueForC tmp =
                new MessageQueueForC(mq.getTopic(), mq.getBrokerName(), mq.getQueueId(), entry.getValue());
        list.add(tmp);
    }

    return list;
}
 
Example 3
Source File: Broker2Client.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private List<MessageQueueForC> convertOffsetTable2OffsetList(Map<MessageQueue, Long> table) {
    List<MessageQueueForC> list = new ArrayList<MessageQueueForC>();
    for (Entry<MessageQueue, Long> entry : table.entrySet()) {
        MessageQueue mq = entry.getKey();
        MessageQueueForC tmp =
                new MessageQueueForC(mq.getTopic(), mq.getBrokerName(), mq.getQueueId(), entry.getValue());
        list.add(tmp);
    }

    return list;
}