Java Code Examples for org.apache.rocketmq.common.message.MessageQueue#getQueueId()

The following examples show how to use org.apache.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-all-4.1.0-incubating 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: MessageListenerOrderlyProxy.java    From pepper-metrics with Apache License 2.0 6 votes vote down vote up
@Override
public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
    long begin = System.currentTimeMillis();
    ConsumeOrderlyStatus status;
    final MessageQueue messageQueue = context.getMessageQueue();
    final String[] tags = {"metric", messageQueue.getTopic() + "-Q" + messageQueue.getQueueId(),
            "namespace", namespace,
            "consumeGroup", consumeGroup,
            "topic", messageQueue.getTopic(),
            "queueId", String.valueOf(messageQueue.getQueueId())};
    stats.incConc(tags);
    try {
        status = target.consumeMessage(msgs, context);
    } catch (Throwable t) {
        stats.error(tags);
        throw t;
    } finally {
        stats.observe(System.currentTimeMillis() - begin, tags);
        stats.decConc(tags);
    }
    return status;
}
 
Example 3
Source File: DefaultMQAdminExtImpl.java    From rocketmq 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 4
Source File: ProducerSendMessageHook.java    From pepper-metrics with Apache License 2.0 6 votes vote down vote up
private String[] tags(SendMessageContext context, Exception e) {
    final MessageQueue messageQueue = context.getMq();
    if (e != null) {
        return new String[]{"metric", messageQueue.getBrokerName() +
                "/" + messageQueue.getTopic() +
                "/Q" + messageQueue.getQueueId(),
                "broker", messageQueue.getBrokerName(),
                "namespace", namespace,
                "topic", messageQueue.getTopic(),
                "queueId", String.valueOf(messageQueue.getQueueId()),
                "exception", e.getClass().getName()};
    } else {
        return new String[]{"metric", messageQueue.getBrokerName() +
                "/" + messageQueue.getTopic() +
                "/Q" + messageQueue.getQueueId(),
                "broker", messageQueue.getBrokerName(),
                "namespace", namespace,
                "topic", messageQueue.getTopic(),
                "queueId", String.valueOf(messageQueue.getQueueId())};
    }
}
 
Example 5
Source File: Broker2Client.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
/**
 * c语言的,不看
 * @param table table
 * @return ;
 */
private List<MessageQueueForC> convertOffsetTable2OffsetList(Map<MessageQueue, Long> table) {
    List<MessageQueueForC> list = new ArrayList<>();
    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 6
Source File: Broker2Client.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
private List<MessageQueueForC> convertOffsetTable2OffsetList(Map<MessageQueue, Long> table) {
    List<MessageQueueForC> list = new ArrayList<>();
    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 7
Source File: DefaultMQAdminExtImpl.java    From DDMQ with Apache License 2.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()))) {
                    if (next.getValue().getConsumerOffset() > msg.getQueueOffset()) {
                        return true;
                    }
                }
            }
        }
    }

    return false;
}
 
Example 8
Source File: Broker2Client.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private List<MessageQueueForC> convertOffsetTable2OffsetList(Map<MessageQueue, Long> table) {
    List<MessageQueueForC> list = new ArrayList<>();
    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 9
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<>();
    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 10
Source File: DefaultMQAdminExtImpl.java    From rocketmq-read with Apache License 2.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 (RemotingUtil.socketAddress2String(msg.getStoreHost()).equals(addr)) {
                    if (next.getValue().getConsumerOffset() > msg.getQueueOffset()) {
                        return true;
                    }
                }
            }
        }
    }

    return false;
}
 
Example 11
Source File: Broker2Client.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
private List<MessageQueueForC> convertOffsetTable2OffsetList(Map<MessageQueue, Long> table) {
    List<MessageQueueForC> list = new ArrayList<>();
    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 12
Source File: ConsumerConsumeMessageHook.java    From pepper-metrics with Apache License 2.0 5 votes vote down vote up
private String[] tags(ConsumeMessageContext context) {
    final MessageQueue messageQueue = context.getMq();
    return new String[]{"metric",
                messageQueue.getBrokerName()
                        + "/" + messageQueue.getTopic()
                        + "/" + context.getConsumerGroup()
                        + "/Q" + messageQueue.getQueueId(),
            "broker", messageQueue.getBrokerName(),
            "namespace", namespace,
            "topic", messageQueue.getTopic(),
            "consumerGroup", context.getConsumerGroup(),
            "queueId", String.valueOf(messageQueue.getQueueId())};
}
 
Example 13
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<>();
    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 14
Source File: Broker2Client.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
private List<MessageQueueForC> convertOffsetTable2OffsetList(Map<MessageQueue, Long> table) {
    List<MessageQueueForC> list = new ArrayList<>();
    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 15
Source File: Broker2Client.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private List<MessageQueueForC> convertOffsetTable2OffsetList(Map<MessageQueue, Long> table) {
    List<MessageQueueForC> list = new ArrayList<>();
    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 16
Source File: RmqAdminServiceImpl.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public static String getNewQid(MessageQueue mq) {
    return mq.getBrokerName() + "_" + mq.getQueueId();
}
 
Example 17
Source File: ClientConfig.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public MessageQueue queueWithNamespace(MessageQueue queue) {
    if (StringUtils.isEmpty(this.getNamespace())) {
        return queue;
    }
    return new MessageQueue(withNamespace(queue.getTopic()), queue.getBrokerName(), queue.getQueueId());
}
 
Example 18
Source File: RmqAdminServiceImpl.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public static String getNewQid(MessageQueue mq) {
    return mq.getBrokerName() + "_" + mq.getQueueId();
}
 
Example 19
Source File: ConsumerLagMonitor.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
private String buildQid(String mqServer, MessageQueue mq) {
    return mqServer + "_" + mq.getBrokerName() + "_" + mq.getQueueId();
}
 
Example 20
Source File: ConsumerLagMonitor.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
private String buildQid(String mqServer, MessageQueue mq) {
    return mqServer + "_" + mq.getBrokerName() + "_" + mq.getQueueId();
}