博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Send [1] times, still failed
阅读量:4327 次
发布时间:2019-06-06

本文共 3499 字,大约阅读时间需要 11 分钟。

com.alibaba.rocketmq.client.exception.MQClientException: Send [1] times, still failed, cost [696094]ms, Topic: TopicTest, BrokersSent: [broker-b, null]See https://github.com/alibaba/RocketMQ/issues/50 for further details.    at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:578)    at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1031)    at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1025)    at com.alibaba.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:95)

 

关键代码片段

final long maxTimeout = this.defaultMQProducer.getSendMsgTimeout() + 1000;        final long beginTimestamp = System.currentTimeMillis();        long endTimestamp = beginTimestamp;        TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());        if (topicPublishInfo != null && topicPublishInfo.ok()) {            MessageQueue mq = null;            Exception exception = null;            SendResult sendResult = null;            int timesTotal = 1 + this.defaultMQProducer.getRetryTimesWhenSendFailed();            int times = 0;            String[] brokersSent = new String[timesTotal];            for (; times < timesTotal && (endTimestamp - beginTimestamp) < maxTimeout; times++) {                String lastBrokerName = null == mq ? null : mq.getBrokerName();                MessageQueue tmpmq = topicPublishInfo.selectOneMessageQueue(lastBrokerName);                if (tmpmq != null) {                    mq = tmpmq;                    brokersSent[times] = mq.getBrokerName();                    try {                        sendResult = this.sendKernelImpl(msg, mq, communicationMode, sendCallback, timeout);                        endTimestamp = System.currentTimeMillis();                        switch (communicationMode) {                        case ASYNC:                            return null;                        case ONEWAY:                            return null;                        case SYNC:                            if (sendResult.getSendStatus() != SendStatus.SEND_OK) {                                if (this.defaultMQProducer.isRetryAnotherBrokerWhenNotStoreOK()) {                                    continue;                                }                            }                            return sendResult;                        default:                            break;                        }                    }                    catch  ... //省略部分代码                }                else {                    break;                }            } // end of for            if (sendResult != null) {                return sendResult;            }            String info =                    String.format("Send [%d] times, still failed, cost [%d]ms, Topic: %s, BrokersSent: %s", //                        times, //                        (System.currentTimeMillis() - beginTimestamp), //                        msg.getTopic(),//                        Arrays.toString(brokersSent));            info += FAQUrl.suggestTodo(FAQUrl.SEND_MSG_FAILED);            throw new MQClientException(info, exception);        }

 

1. 循环几次发送几次

2. selectOneMessageQueue 返回与上一个broker不同名的broker

3. timesTotal  是brokersSent 数组

4. 某broker发送失败时,如果想要重试其他broker,需要把retryAnotherBrokerWhenNotStoreOK设置为true(默认为false)

5. 最大超时时间是在超时时间基础上增加1s(坑?)

转载于:https://www.cnblogs.com/zno2/p/4789208.html

你可能感兴趣的文章
ffmpeg格式转换命令
查看>>
万方数据知识平台 TFHpple +Xpath解析
查看>>
Hive实现oracle的Minus函数
查看>>
秒杀多线程第四篇 一个经典的多线程同步问题
查看>>
RocketMQ配置
查看>>
vs code调试console程序报错--preLaunchTask“build”
查看>>
蚂蚁金服井贤栋:用技术联手金融机构,形成服务小微的生态合力
查看>>
手机通话记录统计分析
查看>>
端口号大全
查看>>
机器学习基石笔记2——在何时可以使用机器学习(2)
查看>>
POJ 3740 Easy Finding (DLX模板)
查看>>
MySQL 处理重复数据
查看>>
关于typedef的用法总结(转)
查看>>
【strtok()】——分割字符串
查看>>
Linux下安装rabbitmq
查看>>
曹德旺
查看>>
【转】判断点在多边形内(matlab)
查看>>
java基础之集合:List Set Map的概述以及使用场景
查看>>
Python 线程 进程 协程
查看>>
iOS语言中的KVO机制
查看>>