Fixed console ISSUE#254 #252 #251

This commit is contained in:
walking98
2019-05-10 17:24:11 +08:00
parent de4884771a
commit 58f84079c0
10 changed files with 40 additions and 16 deletions

View File

@@ -49,8 +49,13 @@ public class TopicController {
@RequestMapping(value = "/list.query", method = RequestMethod.GET) @RequestMapping(value = "/list.query", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public Object list() throws MQClientException, RemotingException, InterruptedException { public Object list(@RequestParam(value = "skipSysProcess", required = false) String skipSysProcess)
return topicService.fetchAllTopicList(); throws MQClientException, RemotingException, InterruptedException {
boolean flag = false;
if ("true".equals(skipSysProcess)) {
flag = true;
}
return topicService.fetchAllTopicList(flag);
} }
@RequestMapping(value = "/stats.query", method = RequestMethod.GET) @RequestMapping(value = "/stats.query", method = RequestMethod.GET)

View File

@@ -29,7 +29,7 @@ import org.apache.rocketmq.console.model.request.TopicConfigInfo;
import java.util.List; import java.util.List;
public interface TopicService { public interface TopicService {
TopicList fetchAllTopicList(); TopicList fetchAllTopicList(boolean skipSysProcess);
TopicStatsTable stats(String topic); TopicStatsTable stats(String topic);

View File

@@ -38,6 +38,7 @@ import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.body.Connection; import org.apache.rocketmq.common.protocol.body.Connection;
import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult; import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
import org.apache.rocketmq.common.protocol.body.ConsumerConnection; import org.apache.rocketmq.common.protocol.body.ConsumerConnection;
import org.apache.rocketmq.console.exception.ServiceException;
import org.apache.rocketmq.console.model.MessageView; import org.apache.rocketmq.console.model.MessageView;
import org.apache.rocketmq.console.service.MessageService; import org.apache.rocketmq.console.service.MessageService;
import org.apache.rocketmq.tools.admin.MQAdminExt; import org.apache.rocketmq.tools.admin.MQAdminExt;
@@ -66,7 +67,7 @@ public class MessageServiceImpl implements MessageService {
return new Pair<>(MessageView.fromMessageExt(messageExt), messageTrackList); return new Pair<>(MessageView.fromMessageExt(messageExt), messageTrackList);
} }
catch (Exception e) { catch (Exception e) {
throw Throwables.propagate(e); throw new ServiceException(-1, String.format("Failed to query message by Id: %s", msgId));
} }
} }

View File

@@ -55,10 +55,14 @@ public class TopicServiceImpl extends AbstractCommonService implements TopicServ
private RMQConfigure rMQConfigure; private RMQConfigure rMQConfigure;
@Override @Override
public TopicList fetchAllTopicList() { public TopicList fetchAllTopicList(boolean skipSysProcess) {
try { try {
TopicList sysTopics = getSystemTopicList();
TopicList allTopics = mqAdminExt.fetchAllTopicList(); TopicList allTopics = mqAdminExt.fetchAllTopicList();
if (skipSysProcess) {
return allTopics;
}
TopicList sysTopics = getSystemTopicList();
Set<String> topics = new HashSet<>(); Set<String> topics = new HashSet<>();
for (String topic: allTopics.getTopicList()) { for (String topic: allTopics.getTopicList()) {

View File

@@ -39,7 +39,7 @@ public class GlobalExceptionHandler {
value = new JsonResult<Object>(((ServiceException) ex).getCode(), ex.getMessage()); value = new JsonResult<Object>(((ServiceException) ex).getCode(), ex.getMessage());
} }
else { else {
value = new JsonResult<Object>(-1, ex.getMessage()); value = new JsonResult<Object>(-1, ex.getMessage() == null ? ex.toString() : ex.getMessage());
} }
} }
return value; return value;

View File

@@ -27,7 +27,10 @@ module.controller('messageController', ['$scope', 'ngDialog', '$http','Notificat
$scope.queryMessageByMessageIdResult={}; $scope.queryMessageByMessageIdResult={};
$http({ $http({
method: "GET", method: "GET",
url: "topic/list.query" url: "topic/list.query",
params: {
skipSysProcess: 'true'
}
}).success(function (resp) { }).success(function (resp) {
if(resp.status ==0){ if(resp.status ==0){
$scope.allTopicList = resp.data.topicList.sort(); $scope.allTopicList = resp.data.topicList.sort();
@@ -57,6 +60,11 @@ module.controller('messageController', ['$scope', 'ngDialog', '$http','Notificat
console.log($scope.selectedTopic); console.log($scope.selectedTopic);
console.log($scope.timepickerBegin) console.log($scope.timepickerBegin)
console.log($scope.timepickerEnd) console.log($scope.timepickerEnd)
if ($scope.timepickerEnd < $scope.timepickerBegin) {
Notification.error({message: "endTime is later than beginTime!", delay: 2000});
return
}
$http({ $http({
method: "GET", method: "GET",
url: "message/queryMessageByTopic.query", url: "message/queryMessageByTopic.query",

View File

@@ -28,7 +28,10 @@ module.controller('messageTraceController', ['$scope', 'ngDialog', '$http','Noti
$http({ $http({
method: "GET", method: "GET",
url: "topic/list.query" url: "topic/list.query",
params: {
skipSysProcess:"true"
}
}).success(function (resp) { }).success(function (resp) {
if(resp.status ==0){ if(resp.status ==0){
$scope.allTopicList = resp.data.topicList.sort(); $scope.allTopicList = resp.data.topicList.sort();

View File

@@ -21,7 +21,10 @@ module.controller('producerController', ['$scope', '$http','Notification',functi
$scope.producerGroup=""; $scope.producerGroup="";
$http({ $http({
method: "GET", method: "GET",
url: "topic/list.query" url: "topic/list.query",
params:{
skipSysProcess:"true"
}
}).success(function (resp) { }).success(function (resp) {
if(resp.status ==0){ if(resp.status ==0){
$scope.allTopicList = resp.data.topicList.sort(); $scope.allTopicList = resp.data.topicList.sort();

View File

@@ -379,10 +379,10 @@
</script> </script>
<!--删除 消费(订阅)--> <!--消费(订阅)详情-->
<script type="text/ng-template" id="consumerTopicViewDialog"> <script type="text/ng-template" id="consumerTopicViewDialog">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title">[{{ngDialogData.consumerGroupName}}]Detail</h4> <h4 class="modal-title">[{{ngDialogData.consumerGroupName}}]{{'CONSUME_DETAIL' | translate}}</h4>
</div> </div>
<div class="modal-body "> <div class="modal-body ">
<table class="table table-bordered table-hover" ng-repeat="consumeDetail in ngDialogData.data"> <table class="table table-bordered table-hover" ng-repeat="consumeDetail in ngDialogData.data">
@@ -396,7 +396,7 @@
<td><label>{{ 'DELAY' | translate }}</label></td> <td><label>{{ 'DELAY' | translate }}</label></td>
<td>{{consumeDetail.diffTotal}}</td> <td>{{consumeDetail.diffTotal}}</td>
<td><label>{{ 'LAST_CONSUME_TIME' | translate }}</label></td> <td><label>{{ 'LAST_CONSUME_TIME' | translate }}</label></td>
<td>{{consumeDetail.lastTimestamp | date:'yyyy-MM-dd HH:mm:ss'}}</td> <td>{{(consumeDetail.lastTimestamp == 0)?"N/A":consumeDetail.lastTimestamp | date:'yyyy-MM-dd HH:mm:ss'}}</td>
</tr> </tr>
</table> </table>
</td> </td>
@@ -422,7 +422,7 @@
<td class="text-center">{{item.brokerOffset}}</td> <td class="text-center">{{item.brokerOffset}}</td>
<td class="text-center">{{item.consumerOffset}}</td> <td class="text-center">{{item.consumerOffset}}</td>
<td class="text-center">{{item.brokerOffset-item.consumerOffset}}</td> <td class="text-center">{{item.brokerOffset-item.consumerOffset}}</td>
<td class="text-center">{{item.lastTimestamp | date:'yyyy-MM-dd HH:mm:ss'}}</td> <td class="text-center">{{(item.lastTimestamp == 0)?"N/A":item.lastTimestamp | date:'yyyy-MM-dd HH:mm:ss'}}</td>
</tr> </tr>
</table> </table>
</td> </td>

View File

@@ -64,7 +64,7 @@ public class TopicServiceImplTest extends RocketMQConsoleTestBase {
@Test @Test
public void fetchAllTopicList() throws Exception { public void fetchAllTopicList() throws Exception {
TopicList topicList = topicService.fetchAllTopicList(); TopicList topicList = topicService.fetchAllTopicList(true);
Assert.assertNotNull(topicList); Assert.assertNotNull(topicList);
Assert.assertTrue(CollectionUtils.isNotEmpty(topicList.getTopicList())); Assert.assertTrue(CollectionUtils.isNotEmpty(topicList.getTopicList()));
Assert.assertTrue(topicList.getTopicList().contains(TEST_CONSOLE_TOPIC)); Assert.assertTrue(topicList.getTopicList().contains(TEST_CONSOLE_TOPIC));
@@ -107,7 +107,7 @@ public class TopicServiceImplTest extends RocketMQConsoleTestBase {
topicConfigInfo.setTopicName(TEST_CREATE_DELETE_TOPIC); topicConfigInfo.setTopicName(TEST_CREATE_DELETE_TOPIC);
topicService.createOrUpdate(topicConfigInfo); topicService.createOrUpdate(topicConfigInfo);
TopicList topicList = topicService.fetchAllTopicList(); TopicList topicList = topicService.fetchAllTopicList(true);
Assert.assertNotNull(topicList); Assert.assertNotNull(topicList);
Assert.assertTrue(CollectionUtils.isNotEmpty(topicList.getTopicList())); Assert.assertTrue(CollectionUtils.isNotEmpty(topicList.getTopicList()));