You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/02/27 14:13:43 UTC

[GitHub] [rocketmq] Cczzzz opened a new pull request #1800: Fix asynchronous send retry

Cczzzz opened a new pull request #1800: Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800
 
 
   retryTimesWhenSendAsyncFailed在DefaultMQProducer中此字段无效。
   
        producer.send(msg, new SendCallback() {
                       @Override
                       public void onSuccess(SendResult sendResult) {
                           countDownLatch.countDown();
                           System.out.printf("%-10d OK %s %n", index, sendResult.getMsgId());
                       }
   
                       @Override
                       public void onException(Throwable e) {
                           countDownLatch.countDown();
                           System.out.printf("%-10d Exception %s %n", index, e);
                           e.printStackTrace();
                       }
                   });
   最后输入MQClientAPIImpl#sendMessageAsync,如果发生异常。
   将调用onExceptionImpl(),但timeoutMillis始终为0。
   
   onExceptionImpl(brokerName,msg,0L,request,sendCallback,topicPublishInfo,instance,
   retryTimesWhenSendFailed,times,ex,context,true,producer);
   
       private void onExceptionImpl(final String brokerName,
                                    final Message msg,
                                    final long timeoutMillis,
                                    final RemotingCommand request,
                                    final SendCallback sendCallback,
                                    final TopicPublishInfo topicPublishInfo,
                                    final MQClientInstance instance,
                                    final int timesTotal,
                                    final AtomicInteger curTimes,
                                    final Exception e,
                                    final SendMessageContext context,
                                    final boolean needRetry,
                                    final DefaultMQProducerImpl producer
       )
   在此将导致发送失败,invokeAsync timeoutMillis为0。
   
   NettyRemotingClient#invokeAsync 
    @Override
       public void invokeAsync(String addr, RemotingCommand request, long timeoutMillis, InvokeCallback invokeCallback)
           throws InterruptedException, RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException,
           RemotingSendRequestException {
           long beginStartTime = System.currentTimeMillis();
           final Channel channel = this.getAndCreateChannel(addr);
           if (channel != null && channel.isActive()) {
               try {
                   doBeforeRpcHooks(addr, request);
                   long costTime = System.currentTimeMillis() - beginStartTime;
                   if (timeoutMillis < costTime) {
                       throw new RemotingTooMuchRequestException("invokeAsync call timeout");
                   }
                   this.invokeAsyncImpl(channel, request, timeoutMillis - costTime, invokeCallback);
               } catch (RemotingSendRequestException e) {
                   log.warn("invokeAsync: send request exception, so close the channel[{}]", addr);
                   this.closeChannel(addr, channel);
                   throw e;
               }
           } else {
               this.closeChannel(addr, channel);
               throw new RemotingConnectException(addr);
           }
       }
   重试时,requestId将被重置,但是会有重复的requestId,并且不会执行回调函数
   
    private volatile int opaque = requestId.getAndIncrement();
      public static int createNewRequestId() {
           return requestId.incrementAndGet();
       }
   crementAndGet和getAndIncrement将导致重复的id。
   我尝试修复它,如果这是一个错误。
   ····································
   关于异步发送试重的问题
   异步发送的重试次数并没有生效,因为在方法中MQClientAPIImpl#sendMessageAsync发送失败后调用时timeoutMillis是0,导致后面超时判断直接判定超时,第一次重试就失败。
   onExceptionImpl(brokerName, msg,0L,request,sendCallback,topicPublishInfo,实例,
   retryTimesWhenSendFailed,时间,ex,上下文,true,生产者);
   然后,在重试时会重置请求id,但是重置的方法和创建request时分配请求id方法会导致出现反复id.incrementAndGet和getAndIncrement一起使用了,导致其他请求的响应影响的异步发送的响应,导致回调函数没有执行,重试中断。
   不知道这是不是一个错误,如果是,我修复了它,希望可以提交rp

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] duhenglucky commented on issue #1800: [ISSUE #1781]Fix asynchronous send retry

Posted by GitBox <gi...@apache.org>.
duhenglucky commented on issue #1800: [ISSUE #1781]Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800#issuecomment-592474725
 
 
   > @duhenglucky thank you, I want to ask how to become to contributor.
   
   Just now, as this PR merged, so thank you very much for your continued participation in the contributing to rocketmq
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] Cczzzz commented on issue #1800: Fix asynchronous send retry

Posted by GitBox <gi...@apache.org>.
Cczzzz commented on issue #1800: Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800#issuecomment-592387309
 
 
   @xujianhai666 首先 incrementAndGet 和 getAndIncrement 一起使用肯定会出现,重复id的,比如我在测试的时候发现发送了两个请求id为11的请求。因为rocket是用map的记录的id为key就导致一个id为11的请求被覆盖了。之后会接受两个11的响应,这样第二的11的响应找不到对应的请求,也就执行不了对应的回调函数了。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] Cczzzz commented on issue #1800: Fix asynchronous send retry

Posted by GitBox <gi...@apache.org>.
Cczzzz commented on issue #1800: Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800#issuecomment-591997938
 
 
   fix  about async send retry #1781 
   https://github.com/apache/rocketmq/issues/1781

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] duhenglucky commented on issue #1800: Fix asynchronous send retry

Posted by GitBox <gi...@apache.org>.
duhenglucky commented on issue #1800: Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800#issuecomment-592392364
 
 
   > @duhenglucky ok , Can I directly modify the branch I want to commit in this pull request.I don't know what to do.Or start a new one pull request
   
   ![image](https://user-images.githubusercontent.com/7938968/75520804-5b56a300-5a41-11ea-8e12-60d8d4801c9c.png)
   
   I have changed it to the develop branch of this PR for you, other PR you can just click the Edit button on the top and change the target branch.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] xujianhai666 commented on issue #1800: Fix asynchronous send retry

Posted by GitBox <gi...@apache.org>.
xujianhai666 commented on issue #1800: Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800#issuecomment-592273977
 
 
   @Cczzzz 请问, `然后,在重试时会重置请求id,但是重置的方法和创建request时分配请求id的方法会导致出现反复id。incrementAndGet 和 getAndIncrement 一起使用了` 这个场景能够说明下吗?没有很理解

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] Cczzzz commented on issue #1800: Fix asynchronous send retry

Posted by GitBox <gi...@apache.org>.
Cczzzz commented on issue #1800: Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800#issuecomment-592394882
 
 
   @duhenglucky  thank you, I want to ask how to become to contribuor

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] duhenglucky merged pull request #1800: [ISSUE #1781]Fix asynchronous send retry

Posted by GitBox <gi...@apache.org>.
duhenglucky merged pull request #1800: [ISSUE #1781]Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] duhenglucky commented on issue #1800: Fix asynchronous send retry

Posted by GitBox <gi...@apache.org>.
duhenglucky commented on issue #1800: Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800#issuecomment-592285653
 
 
   @Cczzzz 
   
   > @Cczzzz 请问, `然后,在重试时会重置请求id,但是重置的方法和创建request时分配请求id的方法会导致出现反复id。incrementAndGet 和 getAndIncrement 一起使用了` 这个场景能够说明下吗?没有很理解
   
   GetAndIncrement will use the incrementAndGet incremented id, and requestId is a class static variable, so this area needs to be fixed, @cczzzz could you submit this PR to the develop branch, RocketMQ use develop branch as the development branch by default.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] Cczzzz commented on issue #1800: Fix asynchronous send retry

Posted by GitBox <gi...@apache.org>.
Cczzzz commented on issue #1800: Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800#issuecomment-592388864
 
 
   @duhenglucky ok , Can I directly modify the branch I want to commit in this pull request.I don't know what to do.Or start a new one pull request 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] xujianhai666 commented on issue #1800: Fix asynchronous send retry

Posted by GitBox <gi...@apache.org>.
xujianhai666 commented on issue #1800: Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800#issuecomment-592274590
 
 
   @Cczzzz 提交规范可以参考: https://github.com/apache/rocketmq/wiki/RIP-14-RocketMQ-Git-Commit-Message-Conventions

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] Cczzzz removed a comment on issue #1800: Fix asynchronous send retry

Posted by GitBox <gi...@apache.org>.
Cczzzz removed a comment on issue #1800: Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800#issuecomment-591997799
 
 
   about async send retry #1781 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq] coveralls commented on issue #1800: Fix asynchronous send retry

Posted by GitBox <gi...@apache.org>.
coveralls commented on issue #1800: Fix asynchronous send retry
URL: https://github.com/apache/rocketmq/pull/1800#issuecomment-592010859
 
 
   
   [![Coverage Status](https://coveralls.io/builds/29000057/badge)](https://coveralls.io/builds/29000057)
   
   Coverage increased (+0.03%) to 50.961% when pulling **be67ff4a9ec8e12f7841d5c82496f6d646491100 on Cczzzz:master** into **73bb4b402a5da02faf9feded8f4d79dd1ba88348 on apache:master**.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services