You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by zh...@apache.org on 2022/12/09 11:53:58 UTC
[rocketmq] 17/26: [ISSUE #5406] Fix brokerName for SEND_MESSAGE_V2
This is an automated email from the ASF dual-hosted git repository.
zhouxzhan pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
commit 274a531321bb10afb2f0bfb0b8d837ced2d8e7af
Author: zhouxiang <zh...@alibaba-inc.com>
AuthorDate: Fri Nov 18 15:46:17 2022 +0800
[ISSUE #5406] Fix brokerName for SEND_MESSAGE_V2
---
.../remoting/activity/AbstractRemotingActivity.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/proxy/src/main/java/org/apache/rocketmq/proxy/remoting/activity/AbstractRemotingActivity.java b/proxy/src/main/java/org/apache/rocketmq/proxy/remoting/activity/AbstractRemotingActivity.java
index 54ef7bfa7..650c38614 100644
--- a/proxy/src/main/java/org/apache/rocketmq/proxy/remoting/activity/AbstractRemotingActivity.java
+++ b/proxy/src/main/java/org/apache/rocketmq/proxy/remoting/activity/AbstractRemotingActivity.java
@@ -25,6 +25,7 @@ import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.protocol.RequestCode;
import org.apache.rocketmq.common.protocol.ResponseCode;
import org.apache.rocketmq.proxy.common.ProxyContext;
import org.apache.rocketmq.proxy.common.ProxyException;
@@ -44,6 +45,7 @@ public abstract class AbstractRemotingActivity implements NettyRequestProcessor
protected final static Logger log = LoggerFactory.getLogger(LoggerName.PROXY_LOGGER_NAME);
protected final MessagingProcessor messagingProcessor;
protected static final String BROKER_NAME_FIELD = "bname";
+ protected static final String BROKER_NAME_FIELD_FOR_SEND_MESSAGE_V2 = "n";
private static final Map<ProxyExceptionCode, Integer> PROXY_EXCEPTION_RESPONSE_CODE_MAP = new HashMap<ProxyExceptionCode, Integer>() {
{
put(ProxyExceptionCode.FORBIDDEN, ResponseCode.NO_PERMISSION);
@@ -61,11 +63,20 @@ public abstract class AbstractRemotingActivity implements NettyRequestProcessor
protected RemotingCommand request(ChannelHandlerContext ctx, RemotingCommand request,
ProxyContext context, long timeoutMillis) throws Exception {
- if (request.getExtFields().get(BROKER_NAME_FIELD) == null) {
- return RemotingCommand.buildErrorResponse(ResponseCode.VERSION_NOT_SUPPORTED,
- "Request doesn't have field bname");
+ String brokerName;
+ if (request.getCode() == RequestCode.SEND_MESSAGE_V2) {
+ if (request.getExtFields().get(BROKER_NAME_FIELD_FOR_SEND_MESSAGE_V2) == null) {
+ return RemotingCommand.buildErrorResponse(ResponseCode.VERSION_NOT_SUPPORTED,
+ "Request doesn't have field bname");
+ }
+ brokerName = request.getExtFields().get(BROKER_NAME_FIELD_FOR_SEND_MESSAGE_V2);
+ } else {
+ if (request.getExtFields().get(BROKER_NAME_FIELD) == null) {
+ return RemotingCommand.buildErrorResponse(ResponseCode.VERSION_NOT_SUPPORTED,
+ "Request doesn't have field bname");
+ }
+ brokerName = request.getExtFields().get(BROKER_NAME_FIELD);
}
- String brokerName = request.getExtFields().get(BROKER_NAME_FIELD);
if (request.isOnewayRPC()) {
messagingProcessor.requestOneway(context, brokerName, request, timeoutMillis);
return null;