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/02 15:14:28 UTC

[GitHub] [rocketmq-dashboard] StyleTang commented on a change in pull request #37: [ISSUE #30]Supports batch resending and batch exporting dlq messages.

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