Java Code Examples for org.apache.rocketmq.common.protocol.ResponseCode#NO_MESSAGE

The following examples show how to use org.apache.rocketmq.common.protocol.ResponseCode#NO_MESSAGE . 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: MQAdminImpl.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public MessageExt viewMessage(String msgId,
    boolean slaveFirst) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {

    MessageId messageId = null;
    try {
        messageId = MessageDecoder.decodeMessageId(msgId);
    } catch (Exception e) {
        throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
    }
    String brokerAddr = RemotingUtil.socketAddress2String(messageId.getAddress());
    if (slaveFirst) {
        TopicRouteData topicRouteData = this.mQClientFactory.getAnExistTopicRouteData(MixAll.DEFAULT_TOPIC);
        if (null == topicRouteData) {
            this.mQClientFactory.updateTopicRouteInfoFromNameServer(MixAll.DEFAULT_TOPIC);
            topicRouteData = this.mQClientFactory.getAnExistTopicRouteData(MixAll.DEFAULT_TOPIC);
        }
        if (topicRouteData != null && topicRouteData.getBrokerDatas() != null) {
            for (BrokerData brokerData : topicRouteData.getBrokerDatas()) {
                if (!brokerData.getBrokerAddrs().isEmpty() && brokerData.getBrokerAddrs().values().contains(brokerAddr)) {
                    Set<Long> ids = new HashSet<Long>(brokerData.getBrokerAddrs().keySet());
                    ids.remove(MixAll.MASTER_ID);
                    if (ids.size() > 0) {
                        brokerAddr = brokerData.getBrokerAddrs().get(ids.iterator().next());
                        log.info("get msg from slave:{}", brokerAddr);
                    }
                }
            }
        }
    }

    return this.mQClientFactory.getMQClientAPIImpl().viewMessage(brokerAddr,
        messageId.getOffset(), timeoutMillis);
}
 
Example 2
Source File: MQAdminImpl.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
public MessageExt viewMessage(
    String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {

    MessageId messageId = null;
    try {
        messageId = MessageDecoder.decodeMessageId(msgId);
    } catch (Exception e) {
        throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
    }
    return this.mQClientFactory.getMQClientAPIImpl().viewMessage(RemotingUtil.socketAddress2String(messageId.getAddress()),
        messageId.getOffset(), timeoutMillis);
}
 
Example 3
Source File: MQAdminImpl.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
/**
 * 根据msgId查询消息
 * @param msgId ;
 * @return ;
 * @throws RemotingException ;
 * @throws MQBrokerException ;
 * @throws InterruptedException ;
 * @throws MQClientException ;
 */
public MessageExt viewMessage(
    String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {

    MessageId messageId;
    try {
        messageId = MessageDecoder.decodeMessageId(msgId);
    } catch (Exception e) {
        throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
    }
    return this.mQClientFactory.getMQClientAPIImpl().viewMessage(RemotingUtil.socketAddress2String(messageId.getAddress()),
        messageId.getOffset(), timeoutMillis);
}
 
Example 4
Source File: MQAdminImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {

        MessageId messageId = null;
        try {
            messageId = MessageDecoder.decodeMessageId(msgId);
        } catch (Exception e) {
            throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
        }
        return this.mQClientFactory.getMQClientAPIImpl().viewMessage(RemotingUtil.socketAddress2String(messageId.getAddress()),
            messageId.getOffset(), timeoutMillis);
    }
 
Example 5
Source File: MQAdminImpl.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public MessageExt viewMessage(String msgId,
    boolean slaveFirst) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {

    MessageId messageId = null;
    try {
        messageId = MessageDecoder.decodeMessageId(msgId);
    } catch (Exception e) {
        throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
    }
    String brokerAddr = RemotingUtil.socketAddress2String(messageId.getAddress());
    if (slaveFirst) {
        TopicRouteData topicRouteData = this.mQClientFactory.getAnExistTopicRouteData(MixAll.DEFAULT_TOPIC);
        if (null == topicRouteData) {
            this.mQClientFactory.updateTopicRouteInfoFromNameServer(MixAll.DEFAULT_TOPIC);
            topicRouteData = this.mQClientFactory.getAnExistTopicRouteData(MixAll.DEFAULT_TOPIC);
        }
        if (topicRouteData != null && topicRouteData.getBrokerDatas() != null) {
            for (BrokerData brokerData : topicRouteData.getBrokerDatas()) {
                if (!brokerData.getBrokerAddrs().isEmpty() && brokerData.getBrokerAddrs().values().contains(brokerAddr)) {
                    Set<Long> ids = new HashSet<Long>(brokerData.getBrokerAddrs().keySet());
                    ids.remove(MixAll.MASTER_ID);
                    if (ids.size() > 0) {
                        brokerAddr = brokerData.getBrokerAddrs().get(ids.iterator().next());
                        log.info("get msg from slave:{}", brokerAddr);
                    }
                }
            }
        }
    }

    return this.mQClientFactory.getMQClientAPIImpl().viewMessage(brokerAddr,
        messageId.getOffset(), timeoutMillis);
}
 
Example 6
Source File: MQAdminImpl.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {

        MessageId messageId = null;
        try {
            messageId = MessageDecoder.decodeMessageId(msgId);
        } catch (Exception e) {
            throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
        }
        return this.mQClientFactory.getMQClientAPIImpl().viewMessage(RemotingUtil.socketAddress2String(messageId.getAddress()),
            messageId.getOffset(), timeoutMillis);
    }
 
Example 7
Source File: MQAdminImpl.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {

        MessageId messageId = null;
        try {
            messageId = MessageDecoder.decodeMessageId(msgId);
        } catch (Exception e) {
            throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
        }
        return this.mQClientFactory.getMQClientAPIImpl().viewMessage(RemotingUtil.socketAddress2String(messageId.getAddress()),
            messageId.getOffset(), timeoutMillis);
    }
 
Example 8
Source File: MQAdminImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public MessageExt viewMessage(
    String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {

    MessageId messageId = null;
    try {
        messageId = MessageDecoder.decodeMessageId(msgId);
    } catch (Exception e) {
        throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
    }
    return this.mQClientFactory.getMQClientAPIImpl().viewMessage(RemotingUtil.socketAddress2String(messageId.getAddress()),
        messageId.getOffset(), timeoutMillis);
}