rocketmq icon indicating copy to clipboard operation
rocketmq copied to clipboard

fix communicationMode

Open liony opened this issue 7 years ago • 4 comments

cause sync as try once , and async can try once more, but this line code is not that meaning, and from the invoke context alse can explain there has some logic wrong.

sync_invoke async_invoke

so change the code:

int timesTotal = communicationMode == CommunicationMode.SYNC ? 1 + this.defaultMQProducer.getRetryTimesWhenSendFailed() : 1;

fix as:

int timesTotal = communicationMode == CommunicationMode.ASYNC ? 1 + this.defaultMQProducer.getRetryTimesWhenSendFailed() : 1;

here is the fixed file: DefaultMQProducerImpl.java

liony avatar Sep 25 '19 03:09 liony

@liony It seems that you want to retry in async mode, actually, async send message wouldn't block the request process and users need to do more in the callback, and sync mode need give users a deterministic return result.

duhenglucky avatar Sep 26 '19 01:09 duhenglucky

@duhenglucky : maybe I drop into a pit intellectually: I want to express that we could not consider whether is sync or not, if user has set retryTimesWhenSendFaied variable a value, then we should help one to retry before the timeout. based on that thinking about above, so I give the suggection for repairing maybe like this:

boolean retryFlag = this.defaultMQProducer.getRetryTimesWhenSendFailed() > 0;
int timesTotal = retryFlag ? this.defaultMQProducer.getRetryTimesWhenSendFailed() : 1;

liony avatar Sep 26 '19 02:09 liony

did you see retryTimesWhenSendAsyncFailed properties @liony

CodeIngL avatar Oct 08 '19 09:10 CodeIngL

@liony as @CodeIngL said if you just want to increase the retry times in async mode, please set retryTimesWhenSendAsyncFailed directly, and more detail can be found in org.apache.rocketmq.client.impl.MQClientAPIImpl#sendMessageAsync, so I will close this issue first, but if you have other questions, please feel free to reopen it.

duhenglucky avatar Oct 08 '19 23:10 duhenglucky