Commit 9b5c3341 by zhiwj

消息路由接口

parent 6a592c03
package com.gic.operation.web.controller;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.error.ErrorCode;
import com.gic.mq.sdk.entity.*;
import com.gic.mq.sdk.entity.response.AddRouterResponse;
import com.gic.mq.sdk.entity.response.DeleteRouterResponse;
import com.gic.mq.sdk.entity.response.UpdateResponse;
import com.gic.mq.sdk.service.MQConfigService;
import com.gic.mq.sdk.service.MQStatusService;
import com.gic.operation.web.vo.RouterConsoleVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
*
* @Description:
* @author zhiwj
* @date 2020/2/13 10:34
*/
@RestController
public class MQController {
@Autowired
private MQConfigService mqConfigService;
@Autowired
private MQStatusService mqStatusService;
@RequestMapping("/routers-list")
public RestResponse queryRouteConfig() {
List<MQRouterEntity> currentRouters = mqConfigService.getCurrentRouters();
return RestResponse.success(currentRouters);
}
@RequestMapping("/add-router")
public RestResponse addRouter(MQRouter mqRouter) {
AddRouterResponse addRouterResponse = mqConfigService.addRouter(mqRouter);
return RestResponse.success(addRouterResponse);
}
@RequestMapping("/update-router")
public RestResponse updateRouter(MQRouter mqRouter) {
UpdateResponse updateResponse = mqConfigService.updateRouter(mqRouter);
return RestResponse.success(updateResponse);
}
@RequestMapping("/del-router")
public RestResponse delRouter(String routerName) {
DeleteRouterResponse deleteRouterResponse = mqConfigService.deleteRouter(routerName);
return RestResponse.success(deleteRouterResponse);
}
/**
* 路由规则状态
* @return
*/
@RequestMapping("/router-running-list")
public RestResponse routerRunningList() {
List<MQRouterRunningInfo> routerRunningInfo = mqStatusService.getRouterRunningInfo();
return RestResponse.success(routerRunningInfo);
}
/**
* 消息队列状态
* @return
*/
@RequestMapping("/channel-infos")
public RestResponse channelInfos() {
List<MQChannelInfo> channelInfos = mqStatusService.getChannelInfos();
return RestResponse.success(channelInfos);
}
/**
* 阻塞队列状态
*/
@RequestMapping("/bloking-key-list")
public RestResponse blokingKeyList() {
List<MQBlockingEntity> blokingKeyList = mqStatusService.getBlokingKeyList();
return RestResponse.success(blokingKeyList);
}
/**
* 控制台
* @return
*/
@RequestMapping("/router-console")
public RestResponse routerConsole() {
// 运行状态
MQStatusInfo runningStatus = mqStatusService.getRunningStatus();
// 配置信息
MQConfigInfo mqConfig = mqConfigService.getMQConfig();
/*
dispatchWorkerNum: 1
readWorkerNum: 3
checkWorkerNum: 1
readingMessageStopped: 0
*/
RouterConsoleVO routerConsoleVO = new RouterConsoleVO();
routerConsoleVO.setMqConfigInfo(mqConfig);
routerConsoleVO.setMqStatusInfo(runningStatus);
return RestResponse.success(routerConsoleVO);
}
@RequestMapping("/update-console")
public RestResponse updateConsole(Integer dispatchWorkerNum, Integer readWorkerNum, Integer checkWorkerNum, Integer readingMessageStopped) {
UpdateResponse updateResponse0 = mqConfigService.updateDispatchWorkerNum(dispatchWorkerNum);
if (!updateResponse0.isSuccess()) {
return RestResponse.failure(ErrorCode.SYSTEM_ERROR.getCode(), updateResponse0.getMessage());
}
UpdateResponse updateResponse1 = mqConfigService.updateReadWorkerNum(readWorkerNum);
if (!updateResponse1.isSuccess()) {
return RestResponse.failure(ErrorCode.SYSTEM_ERROR.getCode(), updateResponse1.getMessage());
}
UpdateResponse updateResponse2 = mqConfigService.updateCheckWorkerNum(checkWorkerNum);
if (!updateResponse2.isSuccess()) {
return RestResponse.failure(ErrorCode.SYSTEM_ERROR.getCode(), updateResponse2.getMessage());
}
UpdateResponse updateResponse3 = mqConfigService.stopReadingMessage(0 == readingMessageStopped);
if (!updateResponse3.isSuccess()) {
return RestResponse.failure(ErrorCode.SYSTEM_ERROR.getCode(), updateResponse3.getMessage());
}
return RestResponse.success();
}
}
\ No newline at end of file
package com.gic.operation.web.vo;
import com.gic.mq.sdk.entity.MQConfigInfo;
import com.gic.mq.sdk.entity.MQStatusInfo;
/**
*
* @Description:
* @author zhiwj
* @date 2020/2/13 17:04
*/
public class RouterConsoleVO {
private MQStatusInfo mqStatusInfo;
private MQConfigInfo mqConfigInfo;
public MQStatusInfo getMqStatusInfo() {
return mqStatusInfo;
}
public void setMqStatusInfo(MQStatusInfo mqStatusInfo) {
this.mqStatusInfo = mqStatusInfo;
}
public MQConfigInfo getMqConfigInfo() {
return mqConfigInfo;
}
public void setMqConfigInfo(MQConfigInfo mqConfigInfo) {
this.mqConfigInfo = mqConfigInfo;
}
}
......@@ -80,4 +80,7 @@
<!--链接小工具-->
<dubbo:reference interface="com.gic.enterprise.service.LinkApiService" id="linkApiService" timeout="6000" />
<dubbo:reference interface="com.gic.auth.service.BusinessFrontResApiService" id="businessFrontResApiService" timeout="6000" />
<!-- 消息路由 -->
<dubbo:reference interface="com.gic.mq.sdk.service.MQConfigService" id="mQConfigService" timeout="6000"/>
<dubbo:reference interface="com.gic.mq.sdk.service.MQStatusService" id="mQStatusService" timeout="6000"/>
</beans>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment