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


Java OMSTimeOutException类代码示例

本文整理汇总了Java中io.openmessaging.exception.OMSTimeOutException的典型用法代码示例。如果您正苦于以下问题:Java OMSTimeOutException类的具体用法?Java OMSTimeOutException怎么用?Java OMSTimeOutException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: checkProducerException

import io.openmessaging.exception.OMSTimeOutException; //导入依赖的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


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