Search in sources :

Example 1 with MQAdminImpl

use of org.apache.rocketmq.client.impl.MQAdminImpl in project rocketmq-externals by apache.

the class MQAdminExtImpl method viewMessage.

// MessageClientIDSetter.getNearlyTimeFromID has bug,so we subtract half a day
// next version we will remove it
// https://issues.apache.org/jira/browse/ROCKETMQ-111
// https://github.com/apache/incubator-rocketmq/pull/69
@Override
public MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    logger.info("MessageClientIDSetter.getNearlyTimeFromID(msgId)={} msgId={}", MessageClientIDSetter.getNearlyTimeFromID(msgId), msgId);
    try {
        return viewMessage(msgId);
    } catch (Exception e) {
    }
    MQAdminImpl mqAdminImpl = MQAdminInstance.threadLocalMqClientInstance().getMQAdminImpl();
    QueryResult qr = Reflect.on(mqAdminImpl).call("queryMessage", topic, msgId, 32, MessageClientIDSetter.getNearlyTimeFromID(msgId).getTime() - 1000 * 60 * 60 * 13L, Long.MAX_VALUE, true).get();
    if (qr != null && qr.getMessageList() != null && qr.getMessageList().size() > 0) {
        return qr.getMessageList().get(0);
    } else {
        return null;
    }
}
Also used : QueryResult(org.apache.rocketmq.client.QueryResult) MQAdminImpl(org.apache.rocketmq.client.impl.MQAdminImpl) MQClientException(org.apache.rocketmq.client.exception.MQClientException) RemotingConnectException(org.apache.rocketmq.remoting.exception.RemotingConnectException) RemotingSendRequestException(org.apache.rocketmq.remoting.exception.RemotingSendRequestException) RemotingTimeoutException(org.apache.rocketmq.remoting.exception.RemotingTimeoutException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RemotingException(org.apache.rocketmq.remoting.exception.RemotingException) RemotingCommandException(org.apache.rocketmq.remoting.exception.RemotingCommandException) MQBrokerException(org.apache.rocketmq.client.exception.MQBrokerException)

Aggregations

UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 QueryResult (org.apache.rocketmq.client.QueryResult)1 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)1 MQClientException (org.apache.rocketmq.client.exception.MQClientException)1 MQAdminImpl (org.apache.rocketmq.client.impl.MQAdminImpl)1 RemotingCommandException (org.apache.rocketmq.remoting.exception.RemotingCommandException)1 RemotingConnectException (org.apache.rocketmq.remoting.exception.RemotingConnectException)1 RemotingException (org.apache.rocketmq.remoting.exception.RemotingException)1 RemotingSendRequestException (org.apache.rocketmq.remoting.exception.RemotingSendRequestException)1 RemotingTimeoutException (org.apache.rocketmq.remoting.exception.RemotingTimeoutException)1