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 2021/11/01 14:36:45 UTC

[GitHub] [rocketmq-dashboard] zhangjidi2016 opened a new pull request #37: [ISSUE #30]Supports batch resending and batch exporting dlq messages.

zhangjidi2016 opened a new pull request #37:
URL: https://github.com/apache/rocketmq-dashboard/pull/37


   ## What is the purpose of the change
   
   #30 
   2.Send and export dead-letter messages in batches.
   
   ## Brief changelog
   
   XX
   
   ## Verifying this change
   
   XXXX
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
   - [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test`  to make sure integration-test pass.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   


-- 
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-dashboard] StyleTang commented on a change in pull request #37: [ISSUE #30]Supports batch resending and batch exporting dlq messages.

Posted by GitBox <gi...@apache.org>.
StyleTang commented on a change in pull request #37:
URL: https://github.com/apache/rocketmq-dashboard/pull/37#discussion_r741161796



##########
File path: src/main/java/org/apache/rocketmq/dashboard/service/impl/DlqMessageServiceImpl.java
##########
@@ -65,4 +68,16 @@ public MessagePage queryDlqMessageByPage(MessageQuery query) {
         }
         return messageService.queryMessageByPage(query);
     }
+
+    @Override
+    public ConsumeMessageDirectlyResult batchResendDlqMessage(List<DlqMessageRequest> dlqMessages) {
+        List<ConsumeMessageDirectlyResult> consumeMessageDirectlyResults = new LinkedList<>();
+        for (DlqMessageRequest dlqMessage : dlqMessages) {
+            ConsumeMessageDirectlyResult consumeMessageDirectlyResult = messageService.consumeMessageDirectly(dlqMessage.getTopicName(),
+                dlqMessage.getMsgId(), dlqMessage.getConsumerGroup(),
+                dlqMessage.getClientId());
+            consumeMessageDirectlyResults.add(consumeMessageDirectlyResult);
+        }
+        return consumeMessageDirectlyResults.get(0);

Review comment:
       Batch resend the message but just get the first result. If we do a batch operation, we should get all the results.

##########
File path: src/main/java/org/apache/rocketmq/dashboard/model/DlqMessageRequest.java
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.dashboard.model;
+

Review comment:
       getters/setters can be generated by `@Data`

##########
File path: src/main/java/org/apache/rocketmq/dashboard/controller/DlqMessageController.java
##########
@@ -70,4 +76,30 @@ public void exportDlqMessage(HttpServletResponse response, @RequestParam String
             throw new ServiceException(-1, String.format("export dlq message failed!"));
         }
     }
+
+    @PostMapping(value = "/batchResendDlqMessage.do")
+    @ResponseBody
+    public Object batchResendDlqMessage(@RequestBody List<DlqMessageRequest> dlqMessages) {
+        return dlqMessageService.batchResendDlqMessage(dlqMessages);
+    }
+
+    @PostMapping(value = "/batchExportDlqMessage.do")
+    public void batchExportDlqMessage(HttpServletResponse response, @RequestBody List<DlqMessageRequest> dlqMessages) {
+        List<DlqMessageExcelModel> dlqMessageExcelModelList = new ArrayList<>(dlqMessages.size());
+        for (DlqMessageRequest dlqMessage : dlqMessages) {
+            try {
+                String topic = MixAll.DLQ_GROUP_TOPIC_PREFIX + dlqMessage.getConsumerGroup();
+                MessageExt messageExt = mqAdminExt.viewMessage(topic, dlqMessage.getMsgId());
+                DlqMessageExcelModel excelModel = new DlqMessageExcelModel(messageExt);
+                dlqMessageExcelModelList.add(excelModel);
+            } catch (Exception e) {
+                log.error("Failed to query message by Id:{}", dlqMessage.getMsgId());

Review comment:
       Maybe returning the failed record with message-id and fail reason is better than just ignoring the exception.
   ```java
   DlqMessageExcelModel excelModel = new DlqMessageExcelModel();
   excelModel.setMessageId(messageId);
   excelModel.setException(error);
   dlqMessageExcelModelList.add(excelModel);
   ```




-- 
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-dashboard] StyleTang commented on a change in pull request #37: [ISSUE #30]Supports batch resending and batch exporting dlq messages.

Posted by GitBox <gi...@apache.org>.
StyleTang commented on a change in pull request #37:
URL: https://github.com/apache/rocketmq-dashboard/pull/37#discussion_r741161796



##########
File path: src/main/java/org/apache/rocketmq/dashboard/service/impl/DlqMessageServiceImpl.java
##########
@@ -65,4 +68,16 @@ public MessagePage queryDlqMessageByPage(MessageQuery query) {
         }
         return messageService.queryMessageByPage(query);
     }
+
+    @Override
+    public ConsumeMessageDirectlyResult batchResendDlqMessage(List<DlqMessageRequest> dlqMessages) {
+        List<ConsumeMessageDirectlyResult> consumeMessageDirectlyResults = new LinkedList<>();
+        for (DlqMessageRequest dlqMessage : dlqMessages) {
+            ConsumeMessageDirectlyResult consumeMessageDirectlyResult = messageService.consumeMessageDirectly(dlqMessage.getTopicName(),
+                dlqMessage.getMsgId(), dlqMessage.getConsumerGroup(),
+                dlqMessage.getClientId());
+            consumeMessageDirectlyResults.add(consumeMessageDirectlyResult);
+        }
+        return consumeMessageDirectlyResults.get(0);

Review comment:
       Batch resend the message but just get the first result. If we do a batch operation, we should get all the results.

##########
File path: src/main/java/org/apache/rocketmq/dashboard/model/DlqMessageRequest.java
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.dashboard.model;
+

Review comment:
       getters/setters can be generated by `@Data`

##########
File path: src/main/java/org/apache/rocketmq/dashboard/controller/DlqMessageController.java
##########
@@ -70,4 +76,30 @@ public void exportDlqMessage(HttpServletResponse response, @RequestParam String
             throw new ServiceException(-1, String.format("export dlq message failed!"));
         }
     }
+
+    @PostMapping(value = "/batchResendDlqMessage.do")
+    @ResponseBody
+    public Object batchResendDlqMessage(@RequestBody List<DlqMessageRequest> dlqMessages) {
+        return dlqMessageService.batchResendDlqMessage(dlqMessages);
+    }
+
+    @PostMapping(value = "/batchExportDlqMessage.do")
+    public void batchExportDlqMessage(HttpServletResponse response, @RequestBody List<DlqMessageRequest> dlqMessages) {
+        List<DlqMessageExcelModel> dlqMessageExcelModelList = new ArrayList<>(dlqMessages.size());
+        for (DlqMessageRequest dlqMessage : dlqMessages) {
+            try {
+                String topic = MixAll.DLQ_GROUP_TOPIC_PREFIX + dlqMessage.getConsumerGroup();
+                MessageExt messageExt = mqAdminExt.viewMessage(topic, dlqMessage.getMsgId());
+                DlqMessageExcelModel excelModel = new DlqMessageExcelModel(messageExt);
+                dlqMessageExcelModelList.add(excelModel);
+            } catch (Exception e) {
+                log.error("Failed to query message by Id:{}", dlqMessage.getMsgId());

Review comment:
       Maybe returning the failed record with message-id and fail reason is better than just ignoring the exception.
   ```java
   DlqMessageExcelModel excelModel = new DlqMessageExcelModel();
   excelModel.setMessageId(messageId);
   excelModel.setException(error);
   dlqMessageExcelModelList.add(excelModel);
   ```




-- 
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-dashboard] StyleTang commented on a change in pull request #37: [ISSUE #30]Supports batch resending and batch exporting dlq messages.

Posted by GitBox <gi...@apache.org>.
StyleTang commented on a change in pull request #37:
URL: https://github.com/apache/rocketmq-dashboard/pull/37#discussion_r741161796



##########
File path: src/main/java/org/apache/rocketmq/dashboard/service/impl/DlqMessageServiceImpl.java
##########
@@ -65,4 +68,16 @@ public MessagePage queryDlqMessageByPage(MessageQuery query) {
         }
         return messageService.queryMessageByPage(query);
     }
+
+    @Override
+    public ConsumeMessageDirectlyResult batchResendDlqMessage(List<DlqMessageRequest> dlqMessages) {
+        List<ConsumeMessageDirectlyResult> consumeMessageDirectlyResults = new LinkedList<>();
+        for (DlqMessageRequest dlqMessage : dlqMessages) {
+            ConsumeMessageDirectlyResult consumeMessageDirectlyResult = messageService.consumeMessageDirectly(dlqMessage.getTopicName(),
+                dlqMessage.getMsgId(), dlqMessage.getConsumerGroup(),
+                dlqMessage.getClientId());
+            consumeMessageDirectlyResults.add(consumeMessageDirectlyResult);
+        }
+        return consumeMessageDirectlyResults.get(0);

Review comment:
       Batch resend the message but just get the first result. If we do a batch operation, we should get all the results.

##########
File path: src/main/java/org/apache/rocketmq/dashboard/model/DlqMessageRequest.java
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.dashboard.model;
+

Review comment:
       getters/setters can be generated by `@Data`

##########
File path: src/main/java/org/apache/rocketmq/dashboard/controller/DlqMessageController.java
##########
@@ -70,4 +76,30 @@ public void exportDlqMessage(HttpServletResponse response, @RequestParam String
             throw new ServiceException(-1, String.format("export dlq message failed!"));
         }
     }
+
+    @PostMapping(value = "/batchResendDlqMessage.do")
+    @ResponseBody
+    public Object batchResendDlqMessage(@RequestBody List<DlqMessageRequest> dlqMessages) {
+        return dlqMessageService.batchResendDlqMessage(dlqMessages);
+    }
+
+    @PostMapping(value = "/batchExportDlqMessage.do")
+    public void batchExportDlqMessage(HttpServletResponse response, @RequestBody List<DlqMessageRequest> dlqMessages) {
+        List<DlqMessageExcelModel> dlqMessageExcelModelList = new ArrayList<>(dlqMessages.size());
+        for (DlqMessageRequest dlqMessage : dlqMessages) {
+            try {
+                String topic = MixAll.DLQ_GROUP_TOPIC_PREFIX + dlqMessage.getConsumerGroup();
+                MessageExt messageExt = mqAdminExt.viewMessage(topic, dlqMessage.getMsgId());
+                DlqMessageExcelModel excelModel = new DlqMessageExcelModel(messageExt);
+                dlqMessageExcelModelList.add(excelModel);
+            } catch (Exception e) {
+                log.error("Failed to query message by Id:{}", dlqMessage.getMsgId());

Review comment:
       Maybe returning the failed record with message-id and fail reason is better than just ignoring the exception.
   ```java
   DlqMessageExcelModel excelModel = new DlqMessageExcelModel();
   excelModel.setMessageId(messageId);
   excelModel.setException(error);
   dlqMessageExcelModelList.add(excelModel);
   ```




-- 
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-dashboard] StyleTang merged pull request #37: [ISSUE #30]Supports batch resending and batch exporting dlq messages.

Posted by GitBox <gi...@apache.org>.
StyleTang merged pull request #37:
URL: https://github.com/apache/rocketmq-dashboard/pull/37


   


-- 
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-dashboard] StyleTang merged pull request #37: [ISSUE #30]Supports batch resending and batch exporting dlq messages.

Posted by GitBox <gi...@apache.org>.
StyleTang merged pull request #37:
URL: https://github.com/apache/rocketmq-dashboard/pull/37


   


-- 
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-dashboard] StyleTang merged pull request #37: [ISSUE #30]Supports batch resending and batch exporting dlq messages.

Posted by GitBox <gi...@apache.org>.
StyleTang merged pull request #37:
URL: https://github.com/apache/rocketmq-dashboard/pull/37






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