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

The following examples show how to use org.apache.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: MessageListenerConcurrentlyProxy.java    From pepper-metrics with Apache License 2.0 6 votes vote down vote up
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
    long begin = System.currentTimeMillis();
    ConsumeConcurrentlyStatus 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 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: 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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
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 12
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;
}