当前位置: 首页>>代码示例>>Java>>正文


Java MQClientException.getResponseCode方法代码示例

本文整理汇总了Java中org.apache.rocketmq.client.exception.MQClientException.getResponseCode方法的典型用法代码示例。如果您正苦于以下问题:Java MQClientException.getResponseCode方法的具体用法?Java MQClientException.getResponseCode怎么用?Java MQClientException.getResponseCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.rocketmq.client.exception.MQClientException的用法示例。


在下文中一共展示了MQClientException.getResponseCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkProducerException

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
OMSRuntimeException checkProducerException(String topic, String msgId, Throwable e) {
    if (e instanceof MQClientException) {
        if (e.getCause() != null) {
            if (e.getCause() instanceof RemotingTimeoutException) {
                return new OMSTimeOutException("-1", String.format("Send message to broker timeout, %dms, Topic=%s, msgId=%s",
                    this.rocketmqProducer.getSendMsgTimeout(), topic, msgId), e);
            } else if (e.getCause() instanceof MQBrokerException || e.getCause() instanceof RemotingConnectException) {
                MQBrokerException brokerException = (MQBrokerException) e.getCause();
                return new OMSRuntimeException("-1", String.format("Received a broker exception, Topic=%s, msgId=%s, %s",
                    topic, msgId, brokerException.getErrorMessage()), e);
            }
        }
        // Exception thrown by local.
        else {
            MQClientException clientException = (MQClientException) e;
            if (-1 == clientException.getResponseCode()) {
                return new OMSRuntimeException("-1", String.format("Topic does not exist, Topic=%s, msgId=%s",
                    topic, msgId), e);
            } else if (ResponseCode.MESSAGE_ILLEGAL == clientException.getResponseCode()) {
                return new OMSMessageFormatException("-1", String.format("A illegal message for RocketMQ, Topic=%s, msgId=%s",
                    topic, msgId), e);
            }
        }
    }
    return new OMSRuntimeException("-1", "Send message to RocketMQ broker failed.", e);
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:27,代码来源:AbstractOMSProducer.java

示例2: resetOffsetNew

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
@Override
public void resetOffsetNew(String consumerGroup, String topic, long timestamp) throws RemotingException, MQBrokerException,
    InterruptedException, MQClientException {
    try {
        this.resetOffsetByTimestamp(topic, consumerGroup, timestamp, true);
    } catch (MQClientException e) {
        if (ResponseCode.CONSUMER_NOT_ONLINE == e.getResponseCode()) {
            this.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, true);
            return;
        }
        throw e;
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:14,代码来源:DefaultMQAdminExtImpl.java


注:本文中的org.apache.rocketmq.client.exception.MQClientException.getResponseCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。