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

The following examples show how to use com.alibaba.rocketmq.common.message.MessageQueue#getQueueId() . 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: DefaultMQAdminExtImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
public boolean consumed(final MessageExt msg, final String group)
        throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
    // 查询消费进度
    ConsumeStats cstats = this.examineConsumeStats(group);

    ClusterInfo ci = this.examineBrokerClusterInfo();

    Iterator<Entry<MessageQueue, OffsetWrapper>> it = cstats.getOffsetTable().entrySet().iterator();
    while (it.hasNext()) {
        Entry<MessageQueue, OffsetWrapper> next = it.next();
        MessageQueue mq = next.getKey();
        if (mq.getTopic().equals(msg.getTopic()) && mq.getQueueId() == msg.getQueueId()) {
            BrokerData brokerData = ci.getBrokerAddrTable().get(mq.getBrokerName());
            if (brokerData != null) {
                String addr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
                if (addr.equals(RemotingUtil.socketAddress2String(msg.getStoreHost()))) {
                    if (next.getValue().getConsumerOffset() > msg.getQueueOffset()) {
                        return true;
                    }
                }
            }
        }
    }

    return false;
}
 
Example 2
Source File: DefaultMQAdminExtImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public boolean consumed(final MessageExt msg, final String group) throws RemotingException, MQClientException, InterruptedException,
        MQBrokerException {
    ConsumeStats cstats = this.examineConsumeStats(group);

    ClusterInfo ci = this.examineBrokerClusterInfo();

    Iterator<Entry<MessageQueue, OffsetWrapper>> it = cstats.getOffsetTable().entrySet().iterator();
    while (it.hasNext()) {
        Entry<MessageQueue, OffsetWrapper> next = it.next();
        MessageQueue mq = next.getKey();
        if (mq.getTopic().equals(msg.getTopic()) && mq.getQueueId() == msg.getQueueId()) {
            BrokerData brokerData = ci.getBrokerAddrTable().get(mq.getBrokerName());
            if (brokerData != null) {
                String addr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
                if (addr.equals(RemotingUtil.socketAddress2String(msg.getStoreHost()))) {
                    /* 检查msg是否已经被消费,根据offset进行比较 */
                if (next.getValue().getConsumerOffset() > msg.getQueueOffset()) {
                    return true;
                }
            }
        }
        }
    }

    /* 还没有被消费 */
    return false;
}
 
Example 3
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 4
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;
}