RongtongJin commented on a change in pull request #2243: URL: https://github.com/apache/rocketmq/pull/2243#discussion_r468971722
########## File path: broker/src/main/java/org/apache/rocketmq/broker/hook/AbortProcessException.java ########## @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.rocketmq.broker.hook; + +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.common.UtilAll; +import org.apache.rocketmq.common.help.FAQUrl; + +/** + * + * This exception is used for broker hooks only : SendMessageHook, ConsumeMessageHook + * This exception is not ignored while executing hooks and it means that + * certain processor should return an immediate error response to the client. The + * error response code is included in AbortProcessException. it's naming might + * be confusing, so feel free to refactor this class. Also when any class implements + * the 2 hook interface mentioned above we should be careful if we want to throw + * an AbortProcessException, because it will change the control flow of broker + * and cause a RemotingCommand return error immediately. So be aware of the side + * effect before throw AbortProcessException in your implementation. + * + * @author youhui.zhang Review comment: Recommended remove @author tag in javadoc ########## File path: client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java ########## @@ -628,6 +628,8 @@ private SendResult sendDefaultImpl( case ResponseCode.NO_BUYER_ID: case ResponseCode.NOT_IN_CURRENT_UNIT: continue; + case ResponseCode.FLOW_CONTROL: + break; Review comment: This break can only jump out of the switch but not out of the for loop ########## File path: broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java ########## @@ -273,8 +274,13 @@ public void executeSendMessageHookBefore(final ChannelHandlerContext ctx, final if (requestHeader != null) { requestHeader.setProperties(context.getMsgProps()); } - } catch (Throwable e) { - // Ignore + } + catch (AbortProcessException e) { + throw e; + } catch (RemotingCommandException e) { + // ignore + } catch (RuntimeException e) { + // ignore Review comment: Is it necessary to print the log ? ---------------------------------------------------------------- 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: [email protected]
