You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "RapperCL (via GitHub)" <gi...@apache.org> on 2023/10/28 14:52:54 UTC

[PR] [ISSUE #7512] Simplify message sending at the basic layer and reduce redundant judgments [rocketmq]

RapperCL opened a new pull request, #7513:
URL: https://github.com/apache/rocketmq/pull/7513

   <!-- Please make sure the target branch is right. In most case, the target branch should be `develop`. -->
   
   ### Which Issue(s) This PR Fixes
   
   <!-- Please ensure that the related issue has already been created, and [link this pull request to that issue using keywords](<https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword>) to ensure automatic closure. -->
   
   Fixes #issue_id
   [issue](https://github.com/apache/rocketmq/issues/7512)
   
   ### Brief Description
   
   <!-- Write a brief description for your pull request to help the maintainer understand the reasons behind your changes. -->
   
   ### How Did You Test This Change?
   
   <!-- In order to ensure the code quality of Apache RocketMQ, we expect every pull request to have undergone thorough testing. -->
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

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


Re: [PR] [ISSUE #7512] Simplify message sending at the basic layer and reduce redundant judgments [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #7513: [ISSUE #7512]  Simplify message sending at the basic layer and reduce redundant judgments
URL: https://github.com/apache/rocketmq/pull/7513


-- 
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: commits-unsubscribe@rocketmq.apache.org

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


Re: [PR] [ISSUE #7512] Simplify message sending at the basic layer and reduce redundant judgments [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7513:
URL: https://github.com/apache/rocketmq/pull/7513#issuecomment-2475078267

   This PR is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR.


-- 
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: commits-unsubscribe@rocketmq.apache.org

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


Re: [PR] [ISSUE #7512] Simplify message sending at the basic layer and reduce redundant judgments [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7513:
URL: https://github.com/apache/rocketmq/pull/7513#issuecomment-2480860248

   This PR was closed because it has been inactive for 3 days since being marked as stale.


-- 
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: commits-unsubscribe@rocketmq.apache.org

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


Re: [PR] [ISSUE #7512] Simplify message sending at the basic layer and reduce redundant judgments [rocketmq]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #7513:
URL: https://github.com/apache/rocketmq/pull/7513#issuecomment-1783861839

   We're currently processing your upload.  This comment will be updated when the results are available.


-- 
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: commits-unsubscribe@rocketmq.apache.org

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


Re: [PR] [ISSUE #7512] Simplify message sending at the basic layer and reduce redundant judgments [rocketmq]

Posted by "joeCarf (via GitHub)" <gi...@apache.org>.
joeCarf commented on code in PR #7513:
URL: https://github.com/apache/rocketmq/pull/7513#discussion_r1391967244


##########
proxy/src/main/java/org/apache/rocketmq/proxy/service/message/ClusterMessageService.java:
##########
@@ -63,17 +65,20 @@ public ClusterMessageService(TopicRouteService topicRouteService, MQClientAPIFac
     public CompletableFuture<List<SendResult>> sendMessage(ProxyContext ctx, AddressableMessageQueue messageQueue,
         List<Message> msgList, SendMessageRequestHeader requestHeader, long timeoutMillis) {
         CompletableFuture<List<SendResult>> future;
+        Message message;
         if (msgList.size() == 1) {
-            future = this.mqClientAPIFactory.getClient().sendMessageAsync(
-                    messageQueue.getBrokerAddr(),
-                    messageQueue.getBrokerName(), msgList.get(0), requestHeader, timeoutMillis)
-                .thenApply(Lists::newArrayList);
+            message = msgList.get(0);
         } else {
-            future = this.mqClientAPIFactory.getClient().sendMessageAsync(
-                    messageQueue.getBrokerAddr(),
-                    messageQueue.getBrokerName(), msgList, requestHeader, timeoutMillis)
-                .thenApply(Lists::newArrayList);
+            requestHeader.setBatch(true);
+            message = MessageBatch.generateFromList(msgList);
+            MessageClientIDSetter.setUniqID(message);
+            ((MessageBatch) message).fillBody();
         }
+        future = this.mqClientAPIFactory.getClient().sendMessageAsync(

Review Comment:
   这个部分的改动似乎没有必要,原有的写法我觉得没什么问题



##########
proxy/src/main/java/org/apache/rocketmq/proxy/service/message/LocalMessageService.java:
##########
@@ -90,22 +90,17 @@ public LocalMessageService(BrokerController brokerController, ChannelManager cha
     @Override
     public CompletableFuture<List<SendResult>> sendMessage(ProxyContext ctx, AddressableMessageQueue messageQueue,
         List<Message> msgList, SendMessageRequestHeader requestHeader, long timeoutMillis) {
-        byte[] body;
-        String messageId;
-        if (msgList.size() > 1) {
-            requestHeader.setBatch(true);
-            MessageBatch msgBatch = MessageBatch.generateFromList(msgList);
-            MessageClientIDSetter.setUniqID(msgBatch);
-            body = msgBatch.encode();
-            msgBatch.setBody(body);
-            messageId = MessageClientIDSetter.getUniqID(msgBatch);
+        Message message;

Review Comment:
   判断条件变了一下,带来什么优化了吗



##########
client/src/main/java/org/apache/rocketmq/client/impl/mqclient/MQClientAPIExt.java:
##########
@@ -152,7 +150,9 @@ public CompletableFuture<SendResult> sendMessageAsync(
         long timeoutMillis
     ) {
         SendMessageRequestHeaderV2 requestHeaderV2 = SendMessageRequestHeaderV2.createSendMessageRequestHeaderV2(requestHeader);
-        RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.SEND_MESSAGE_V2, requestHeaderV2);
+
+        int code = requestHeader.isBatch() ? RequestCode.SEND_BATCH_MESSAGE : RequestCode.SEND_MESSAGE_V2;

Review Comment:
   code使用RequestCode类型,可读性会更好



##########
proxy/src/main/java/org/apache/rocketmq/proxy/service/message/ClusterMessageService.java:
##########
@@ -63,17 +65,20 @@ public ClusterMessageService(TopicRouteService topicRouteService, MQClientAPIFac
     public CompletableFuture<List<SendResult>> sendMessage(ProxyContext ctx, AddressableMessageQueue messageQueue,
         List<Message> msgList, SendMessageRequestHeader requestHeader, long timeoutMillis) {
         CompletableFuture<List<SendResult>> future;
+        Message message;
         if (msgList.size() == 1) {
-            future = this.mqClientAPIFactory.getClient().sendMessageAsync(
-                    messageQueue.getBrokerAddr(),
-                    messageQueue.getBrokerName(), msgList.get(0), requestHeader, timeoutMillis)
-                .thenApply(Lists::newArrayList);
+            message = msgList.get(0);
         } else {
-            future = this.mqClientAPIFactory.getClient().sendMessageAsync(
-                    messageQueue.getBrokerAddr(),
-                    messageQueue.getBrokerName(), msgList, requestHeader, timeoutMillis)
-                .thenApply(Lists::newArrayList);
+            requestHeader.setBatch(true);
+            message = MessageBatch.generateFromList(msgList);
+            MessageClientIDSetter.setUniqID(message);
+            ((MessageBatch) message).fillBody();
         }
+        future = this.mqClientAPIFactory.getClient().sendMessageAsync(

Review Comment:
   这个部分的改动似乎没有必要,原有的写法我觉得没什么问题



##########
client/src/main/java/org/apache/rocketmq/client/impl/mqclient/MQClientAPIExt.java:
##########
@@ -152,7 +150,9 @@ public CompletableFuture<SendResult> sendMessageAsync(
         long timeoutMillis
     ) {
         SendMessageRequestHeaderV2 requestHeaderV2 = SendMessageRequestHeaderV2.createSendMessageRequestHeaderV2(requestHeader);
-        RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.SEND_MESSAGE_V2, requestHeaderV2);
+
+        int code = requestHeader.isBatch() ? RequestCode.SEND_BATCH_MESSAGE : RequestCode.SEND_MESSAGE_V2;

Review Comment:
   code使用RequestCode类型,可读性会更好



##########
proxy/src/main/java/org/apache/rocketmq/proxy/service/message/LocalMessageService.java:
##########
@@ -90,22 +90,17 @@ public LocalMessageService(BrokerController brokerController, ChannelManager cha
     @Override
     public CompletableFuture<List<SendResult>> sendMessage(ProxyContext ctx, AddressableMessageQueue messageQueue,
         List<Message> msgList, SendMessageRequestHeader requestHeader, long timeoutMillis) {
-        byte[] body;
-        String messageId;
-        if (msgList.size() > 1) {
-            requestHeader.setBatch(true);
-            MessageBatch msgBatch = MessageBatch.generateFromList(msgList);
-            MessageClientIDSetter.setUniqID(msgBatch);
-            body = msgBatch.encode();
-            msgBatch.setBody(body);
-            messageId = MessageClientIDSetter.getUniqID(msgBatch);
+        Message message;

Review Comment:
   判断条件变了一下,带来什么优化了吗



-- 
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: commits-unsubscribe@rocketmq.apache.org

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