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 2022/01/07 10:04:57 UTC

[GitHub] [rocketmq] crazy-pizza opened a new issue #3731: SendMessageBack has two problems

crazy-pizza opened a new issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731


   1: try内的发送没有校验broker是否是只读,这对运维来说很重要,运维会发现broker设置只读后还是有流量打入。
   2:catch内的兜底发送没有使用用户设置的delayLevelWhenNextConsume,不过如果使用delayLevelWhenNextConsume,也需要考虑delayLevelWhenNextConsume是否超过了消费组的最大重试次数。
   
   ``` java
   public class DefaultMQPushConsumerImpl implements MQConsumerInner {
   
       public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName)
           throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
           try {
               String brokerAddr = (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
                   : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
               this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg,
                   this.defaultMQPushConsumer.getConsumerGroup(), delayLevel, 5000, getMaxReconsumeTimes());
           } catch (Exception e) {
               log.error("sendMessageBack Exception, " + this.defaultMQPushConsumer.getConsumerGroup(), e);
   
               Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup()), msg.getBody());
   
               String originMsgId = MessageAccessor.getOriginMessageId(msg);
               MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
   
               newMsg.setFlag(msg.getFlag());
               MessageAccessor.setProperties(newMsg, msg.getProperties());
               MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
               MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes() + 1));
               MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(getMaxReconsumeTimes()));
               MessageAccessor.clearProperty(newMsg, MessageConst.PROPERTY_TRANSACTION_PREPARED);
               newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
   
               this.mQClientFactory.getDefaultMQProducer().send(newMsg);
           } finally {
               msg.setTopic(NamespaceUtil.withoutNamespace(msg.getTopic(), this.defaultMQPushConsumer.getNamespace()));
           }
       }
   }
   ```


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] crazy-pizza edited a comment on issue #3731: BUG:SendMessageBack didn't use delayLevelWhenNextConsume when broker is crash

Posted by GitBox <gi...@apache.org>.
crazy-pizza edited a comment on issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731#issuecomment-1009645516


   @Git-Yang  如果consumerSendMessageBack失败,仍然会进到延时队列的,详见:`newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());`
   
   另外,broker设置只读后,仍然会执行consumerSendMessageBack。
   
   我只是提个建议,指出一些问题点。


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] crazy-pizza edited a comment on issue #3731: BUG:SendMessageBack didn't use delayLevelWhenNextConsume when broker is crash

Posted by GitBox <gi...@apache.org>.
crazy-pizza edited a comment on issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731#issuecomment-1009645516


   @Git-Yang consumerSendMessageBack不也是发送到 retry topic吗?区别只是在于发送到哪个broker,客户端需不需要携带消息内容。
   站在用户角度考虑,这是个问题,不过问题不容易出现,影响也还好。


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] crazy-pizza edited a comment on issue #3731: BUG:SendMessageBack didn't use delayLevelWhenNextConsume when broker is crash

Posted by GitBox <gi...@apache.org>.
crazy-pizza edited a comment on issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731#issuecomment-1009645516


   @Git-Yang  如果consumerSendMessageBack失败,仍然会进到延时队列的,详见:https://github.com/apache/rocketmq/blob/1b420cedfd74cf47b788abb4599f98d2a5217faf/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java#L533
   
   另外,broker设置只读后,仍然会执行consumerSendMessageBack,失败重试消息的流量仍然会进入到只读的broker。
   
   我只是提个建议,指出一些问题点。


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] crazy-pizza edited a comment on issue #3731: BUG:SendMessageBack didn't use delayLevelWhenNextConsume when broker is crash

Posted by GitBox <gi...@apache.org>.
crazy-pizza edited a comment on issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731#issuecomment-1009645516


   @Git-Yang consumerSendMessageBack不也是发送到 retry topic吗?区别只是在于发送到哪个broker,客户端发送时需不需要携带消息内容。
   站在用户角度考虑,这是个问题,不过问题不容易出现,影响也还好。
   
   另外,broker设置只读后,仍然会执行consumerSendMessageBack


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] crazy-pizza edited a comment on issue #3731: BUG:SendMessageBack didn't use delayLevelWhenNextConsume when broker is crash

Posted by GitBox <gi...@apache.org>.
crazy-pizza edited a comment on issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731#issuecomment-1009645516


   @Git-Yang consumerSendMessageBack不也是发送到 retry topic吗?区别只是在于发送到哪个broker,客户端需不需要携带消息内容。
   站在用户角度考虑,这是个问题,不过问题不容易出现,影响也还好。
   
   另外,broker设置只读后,仍然会执行consumerSendMessageBack


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] Git-Yang commented on issue #3731: BUG:SendMessageBack didn't use delayLevelWhenNextConsume when broker is crash

Posted by GitBox <gi...@apache.org>.
Git-Yang commented on issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731#issuecomment-1008504486


   If consumerSendMessageBack fails, the message will be sent directly to the retry topic without entering the delay queue, so delayLevelWhenNextConsume is not used.


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] crazy-pizza edited a comment on issue #3731: BUG:SendMessageBack didn't use delayLevelWhenNextConsume when broker is crash

Posted by GitBox <gi...@apache.org>.
crazy-pizza edited a comment on issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731#issuecomment-1009645516


   @Git-Yang consumerSendMessageBack不也是发送到 retry topic吗?区别只是在于发送到哪个broker,客户端发送时需不需要携带消息内容。
   站在用户角度考虑,这是个问题,不过问题不容易出现,影响也还好。
   
   另外,broker设置只读后,仍然会执行consumerSendMessageBack。
   
   我只是提个建议,指出一些问题点。


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] crazy-pizza commented on issue #3731: BUG:SendMessageBack didn't use delayLevelWhenNextConsume when broker is crash

Posted by GitBox <gi...@apache.org>.
crazy-pizza commented on issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731#issuecomment-1009645516


   consumerSendMessageBack不也是发送到 retry topic吗?区别只是在于发送到哪个broker,客户端需不需要携带消息内容。
   站在用户角度考虑,这是个问题,不过问题不容易出现,影响也还好。


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] crazy-pizza edited a comment on issue #3731: BUG:SendMessageBack didn't use delayLevelWhenNextConsume when broker is crash

Posted by GitBox <gi...@apache.org>.
crazy-pizza edited a comment on issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731#issuecomment-1009645516


   @Git-Yang  如果consumerSendMessageBack失败,仍然会进到延时队列的,详见:https://github.com/apache/rocketmq/blob/1b420cedfd74cf47b788abb4599f98d2a5217faf/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java#L533
   
   另外,broker设置只读后,仍然会执行consumerSendMessageBack,流量仍然会进入到只读的broker。
   
   我只是提个建议,指出一些问题点。


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] crazy-pizza edited a comment on issue #3731: BUG:SendMessageBack didn't use delayLevelWhenNextConsume when broker is crash

Posted by GitBox <gi...@apache.org>.
crazy-pizza edited a comment on issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731#issuecomment-1009645516






-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] crazy-pizza edited a comment on issue #3731: BUG:SendMessageBack didn't use delayLevelWhenNextConsume when broker is crash

Posted by GitBox <gi...@apache.org>.
crazy-pizza edited a comment on issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731#issuecomment-1009645516


   @Git-Yang  如果consumerSendMessageBack失败,仍然会进到延时队列的,详见:https://github.com/apache/rocketmq/blob/1b420cedfd74cf47b788abb4599f98d2a5217faf/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java#L533
   
   另外,broker设置只读后,仍然会执行consumerSendMessageBack,发送消息的流量仍然会进入到只读的broker。
   
   我只是提个建议,指出一些问题点。


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] crazy-pizza edited a comment on issue #3731: BUG:SendMessageBack didn't use delayLevelWhenNextConsume when broker is crash

Posted by GitBox <gi...@apache.org>.
crazy-pizza edited a comment on issue #3731:
URL: https://github.com/apache/rocketmq/issues/3731#issuecomment-1009645516


   @Git-Yang  如果consumerSendMessageBack失败,仍然会进到延时队列的,详见:https://github.com/apache/rocketmq/blob/1b420cedfd74cf47b788abb4599f98d2a5217faf/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java#L533
   
   另外,broker设置只读后,仍然会执行consumerSendMessageBack,失败的重试消息的流量仍然会进入到只读的broker。
   
   我只是提个建议,指出一些问题点。


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org