fix: Add consumer global refresh and fix the problem #290 (#291)

This commit is contained in:
Xu Yichi
2025-04-15 09:49:34 +08:00
committed by GitHub
parent bbabd1cd0d
commit a450594ace
5 changed files with 47 additions and 5 deletions

View File

@@ -58,6 +58,12 @@ public class ConsumerController {
return consumerService.refreshGroup(address, consumerGroup);
}
@RequestMapping(value = "group.refresh.all")
@ResponseBody
public Object refreshAll(String address) {
return consumerService.refreshAllGroup(address);
}
@RequestMapping(value = "/group.query")
@ResponseBody
public Object groupQuery(@RequestParam String consumerGroup, String address) {

View File

@@ -57,4 +57,6 @@ public interface ConsumerService {
ConsumerRunningInfo getConsumerRunningInfo(String consumerGroup, String clientId, boolean jstack);
Object refreshGroup(String address, String consumerGroup);
Object refreshAllGroup(String address);
}

View File

@@ -529,6 +529,7 @@ public class ConsumerServiceImpl extends AbstractCommonService implements Consum
if (groupConsumeInfo.getGroup().equals(consumerGroup)) {
GroupConsumeInfo updatedInfo = queryGroup(consumerGroup, "");
updatedInfo.setUpdateTime(new Date());
updatedInfo.setGroup(consumerGroup);
cacheConsumeInfoList.set(i, updatedInfo);
return updatedInfo;
}
@@ -536,4 +537,10 @@ public class ConsumerServiceImpl extends AbstractCommonService implements Consum
}
throw new RuntimeException("No consumer group information available");
}
@Override
public List<GroupConsumeInfo> refreshAllGroup(String address) {
cacheConsumeInfoList.clear();
return queryGroupList(false, address);
}
}

View File

@@ -98,7 +98,7 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
});
}
$scope.refreshConsumerData = function () {
$scope.queryConsumerData = function () {
//Show loader
$('#loaderConsumer').removeClass("hide-myloader");
@@ -123,6 +123,30 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
}
});
};
$scope.refreshConsumerData = function () {
//Show loader
$('#loaderConsumer').removeClass("hide-myloader");
$http({
method: "GET",
url: "consumer/group.refresh.all",
params: {
skipSysGroup: false
}
}).success(function (resp) {
if (resp.status == 0) {
$scope.allConsumerGrouopList = resp.data;
console.log($scope.allConsumerGrouopList);
console.log(JSON.stringify(resp));
$scope.showConsumerGroupList($scope.paginationConf.currentPage, $scope.allConsumerGrouopList.length);
//Hide loader
$('#loaderConsumer').addClass("hide-myloader");
} else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
};
$scope.monitor = function (consumerGroupName) {
$http({
method: "GET",
@@ -148,12 +172,12 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
$scope.intervalProcess = null;
}
if ($scope.intervalProcessSwitch) {
$scope.intervalProcess = setInterval($scope.refreshConsumerData, 10000);
$scope.intervalProcess = setInterval($scope.queryConsumerData, 10000);
}
});
$scope.refreshConsumerData();
$scope.queryConsumerData();
$scope.filterStr = "";
$scope.$watch('filterStr', function () {
$scope.paginationConf.currentPage = 1;
@@ -255,7 +279,7 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
ngDialog.open({
preCloseCallback: function (value) {
// Refresh topic list
$scope.refreshConsumerData();
$scope.queryConsumerData();
},
template: $scope.rmqVersion ? 'consumerModifyDialogForV5' : 'consumerModifyDialog',
controller: 'consumerModifyDialogController',
@@ -339,7 +363,7 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
ngDialog.open({
preCloseCallback: function (value) {
// Refresh topic list
$scope.refreshConsumerData();
$scope.queryConsumerData();
},
template: 'deleteConsumerDialog',
controller: 'deleteConsumerDialogController',

View File

@@ -33,6 +33,9 @@
<button class="btn btn-raised btn-sm btn-primary" type="button" ng-show="{{writeOperationEnabled}}"
ng-click="openAddDialog()">{{'ADD' | translate}}/ {{'UPDATE' | translate}}
</button>
<button class="btn btn-raised btn-sm btn-primary" type="button" ng-click="refreshConsumerData()">
{{'REFRESH' | translate}}
</button>
<md-switch class="md-primary" md-no-ink aria-label="Switch No Ink" ng-model="intervalProcessSwitch">
{{'AUTO_REFRESH' | translate}}
</md-switch>