Send [1] times, still failed

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.