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)
Key Code Snippets
Final LongMaxtimeout = This. Defaultmqproducer.getsendmsgtimeout () + 1000; Final LongBegintimestamp =System.currenttimemillis (); LongEndtimestamp =Begintimestamp; Topicpublishinfo Topicpublishinfo= This. Trytofindtopicpublishinfo (Msg.gettopic ()); if(Topicpublishinfo! =NULL&&Topicpublishinfo.ok ()) {MessageQueue MQ=NULL; Exception Exception=NULL; Sendresult Sendresult=NULL; intTimestotal = 1 + This. defaultmqproducer.getretrytimeswhensendfailed (); intTimes = 0; String[] Brokerssent=NewString[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) { CaseASYNC:return NULL; CaseONEWAY:return NULL; CaseSYNC:if(Sendresult.getsendstatus ()! =SENDSTATUS.SEND_OK) { if( This. Defaultmqproducer.isretryanotherbrokerwhennotstoreok ()) { Continue; } } returnSendresult; default: Break; } } Catch...//omit part of the code } Else { Break; } } //End of for if(Sendresult! =NULL) { returnSendresult; } 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 NewMqclientexception (info, exception); }
1. The loop is sent several times
2. Selectonemessagequeue returns a broker with a different name from the previous broker
3. Timestotal is the brokerssent array
4. When a broker fails to send, if you want to retry another broker, you need to set Retryanotherbrokerwhennotstoreok to True (default is False)
5. The maximum time-out is 1s (pit) based on the time-out period. )
Send [1] times, still failed