[Issue #3556] Fix:When broker is down, rocketmq client can not retry under Async send model#3555
[Issue #3556] Fix:When broker is down, rocketmq client can not retry under Async send model#3555odbozhou merged 9 commits intoapache:developfrom lwclover:develop
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #3555 +/- ##
=============================================
- Coverage 47.32% 47.02% -0.31%
+ Complexity 5038 4858 -180
=============================================
Files 627 636 +9
Lines 41348 42249 +901
Branches 5372 5521 +149
=============================================
+ Hits 19568 19867 +299
- Misses 19356 19891 +535
- Partials 2424 2491 +67
Continue to review full report at Codecov.
|
|
Asynchronous retry is here, in class private SendResult sendKernelImpl(final Message msg,
final MessageQueue mq,
final CommunicationMode communicationMode,
final SendCallback sendCallback,
final TopicPublishInfo topicPublishInfo,
final long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
// ...
// line#843:
sendResult = this.mQClientFactory.getMQClientAPIImpl().sendMessage(
brokerAddr,
mq.getBrokerName(),
tmpMessage,
requestHeader,
timeout - costTimeAsync,
communicationMode,
sendCallback,
topicPublishInfo,
this.mQClientFactory,
this.defaultMQProducer.getRetryTimesWhenSendAsyncFailed(),
context,
this);
} |
This is when the broker can connect to, But when can not connect to the broker, can not retry |
|
In the asynchronous sending mode, the sendCallBack function will be called back after the message fails to be sent, and it can be re-sent inside. |
the code 'if (channel != null && channel.isActive()) ' return false, it direct throws RemotingConnectException |
I know what you mean, but if you increase the timesTotal in "for (; times < timesTotal; times++) , the number of retries will become retryTimesWhenSendAsyncFailed² times. Because in addition to the situation you described, there will be retryTimesWhenSendAsyncFailed retry attempts at "this.mQClientFactory.getMQClientAPIImpl().sendMessage" |
|
Agree, in the asynchronous sending mode, there is no retry when the connection establishment fails, and only when the request and response fail. |
No, after trying retryTimesWhenSendAsyncFailed times, it calls callback.onException method. |
Thank you for labeling the bug |
|
@lwclover you are right. Retry for send async is made for the execution of "org.apache.rocketmq.remoting.netty.NettyRemotingAbstract#invokeAsyncImpl", but in the given case, "invokeAsyncImpl" has not been executed yet. |
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
Outdated
Show resolved
Hide resolved
|
Backoff strategy optimization is one of the spots that I would most like to see in RocketMQ. You should consider the retry tuple in here, when you get callback invoked. you have finished the retry in async mode. |
|
|
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
Outdated
Show resolved
Hide resolved
|
@lwclover Would you like to pay more attention to the failed tests: MQClientAPIImplTest.testSendMessageAsync_WithException:201 » NullPointer |
…retry under Async send model (apache#3555)
…retry under Async send model (apache#3555)
…retry under Async send model (apache#3555)



Fix Issue[3556]
RocketMQ client updates topic route infomations every 30 seconds,
When broker is down,Rocketmq client can not connect to the broker. Sending async message can not retry,Throwing a RemotingConnectException.
The RemotingConnectException below:
The RemotingConnectException caused by: throw new RemotingConnectException(addr);
CommunicationMode.Async retry times is 1, when throws RemotingConnectException can not retry.