Skip to content

Commit

Permalink
队列详情页
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyx0912 committed Aug 13, 2022
1 parent c690d88 commit c7e53fb
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 55 deletions.
8 changes: 4 additions & 4 deletions xymq-cli/src/main/java/com/xymq_cli/client/Producer.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ public static void main(String[] args) throws InterruptedException {
Producer producer = new Producer();
// producer.publishDelayTopicMessage("你好,延时30s","topic",30,TimeUnit.SECONDS);
// 推送普通的队列消息
// for (int i = 0; i < 10; i++) {
// producer.sendMsg("你好,我是队列消息"+i,"queue2");
// }
for (int i = 0; i < 10; i++) {
producer.sendMsg("你好,我是队列消息"+i,"queue2");
}
// Thread.sleep(300);
// 推送主题消息
producer.publish("你好,我是主题消息","topic");
// producer.publish("你好,我是主题消息","topic");
// // 推送延迟消息,设置延迟数和单位,消息会在5分钟后推送给消费者
// producer.sendDelayMessage("你好,我是延时队列消息","queueDelayM",5,TimeUnit.SECONDS);
// // 推送延迟主题消息
Expand Down
34 changes: 34 additions & 0 deletions xymq-server/src/main/java/com/xymq_cli/core/XymqServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.xymq_cli.constant.Destination;
import com.xymq_cli.constant.ServerConstant;
import com.xymq_cli.execution.AckExec;
import com.xymq_cli.web.domain.QueueVO;
import com.xymq_common.message.Message;
import com.xymq_common.protocol.MessageUtils;
import io.netty.bootstrap.ServerBootstrap;
Expand Down Expand Up @@ -631,4 +632,37 @@ public int compare(Map.Entry<String, Long> o1, Map.Entry<String, Long> o2) {
public Long topicSuccessCount(){
return topicSuccess.longValue();
}

/**
* 获取队列详情
* @return java.util.List<com.xymq_cli.web.domain.QueueVO>
* @author 黎勇炫
* @create 2022/8/13
* @email [email protected]
*/
public List<QueueVO> queueDetails(){
List<QueueVO> l = new ArrayList<>();
// 遍历队列消息容器
for (String key : queueContainer.keySet()) {
QueueVO vo = new QueueVO();
// key为队列名
vo.setQueueName(key);
// 未消费数量
if(delayQueueContainer.containsKey(key)){
Integer delayCount = delayQueueContainer.get(key).size();
vo.setUnConsume((long) (queueContainer.get(key).size()+delayQueueContainer.get(key).size()));
vo.setDelayCount((long)delayCount);
}else{
vo.setUnConsume((long) queueContainer.get(key).size());
}
// 该队列的消费者
if(consumerContainer.containsKey(key)){
vo.setConsumerCount(consumerContainer.get(key).size());
}else{
vo.setConsumerCount(0);
}
l.add(vo);
}
return l;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
* @author 黎勇炫
* @date 2022年08月01日 22:15
Expand All @@ -24,4 +22,9 @@ public class DataController {
public String queueCharts(){
return JSON.toJSONString(dataChartService.queueData());
}

@GetMapping("/list")
public String queueDetail(){
return JSON.toJSONString(dataChartService.queueDetail());
}
}
18 changes: 15 additions & 3 deletions xymq-server/src/main/java/com/xymq_cli/web/domain/QueueVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@
@Data
public class QueueVO {

/**
* 队列名称
*/
private String queueName;
private String type;
private Integer consumerCount;
private String unConsume;
/**
* 客户端数量
*/
private Integer consumerCount = 0;
/**
* 消息堆积数量
*/
private Long unConsume = 0L;
/**
* 延时消息数量
*/
private Long delayCount = 0L;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.xymq_cli.web.service;

import com.xymq_cli.web.domain.QueueVO;

import java.util.List;
import java.util.Map;

/**
Expand All @@ -26,4 +29,6 @@ public interface DataChartService {
* @email [email protected]
*/
public void updateData();

public List<QueueVO> queueDetail();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.xymq_cli.core.XymqServer;
import com.xymq_cli.execution.AckExec;
import com.xymq_cli.execution.ProducerExec;
import com.xymq_cli.web.domain.QueueVO;
import com.xymq_cli.web.service.DataChartService;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
Expand Down Expand Up @@ -201,4 +202,9 @@ public void updateData(){
channel.writeAndFlush(new TextWebSocketFrame(JSON.toJSONString(queueData())));
}
}

@Override
public List<QueueVO> queueDetail() {
return xymqServer.queueDetails();
}
}
60 changes: 14 additions & 46 deletions xymq-server/src/main/resources/templates/components/queue.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
<template>
<div style="margin-top: 20px">
<el-table
:data="tableData"
:data="queueList"
style="width: 100%">
<el-table-column
fixed
prop="date"
label="序号"
width="50">
</el-table-column>
<el-table-column
prop="name"
prop="queueName"
label="队列名">
</el-table-column>
<el-table-column
prop="province"
prop="consumerCount"
label="消费者数量"
width="200">
</el-table-column>
<el-table-column
prop="city"
label="队列类型"
width="120">
prop="delayCount"
label="延时消息"
width="100">
</el-table-column>
<el-table-column
prop="address"
label="消息数"
prop="unConsume"
label="待消费"
width="100">
</el-table-column>
<el-table-column
Expand All @@ -46,43 +40,17 @@ export default {
name: "index",
data(){
return{
tableData: [{
date: '1',
name: '王小虎',
province: '上海',
city: '普陀区',
address: '上海市普陀区金沙江路 1518 弄',
zip: 200333
}, {
date: '1',
name: '王小虎',
province: '上海',
city: '普陀区',
address: '上海市普陀区金沙江路 1517 弄',
zip: 200333
}, {
date: '1',
name: '王小虎',
province: '上海',
city: '普陀区',
address: '上海市普陀区金沙江路 1519 弄',
zip: 200333
}, {
date: '1',
name: '王小虎',
province: '上海',
city: '普陀区',
address: '上海市普陀区金沙江路 1516 弄',
zip: 200333
}]
queueList:[]
}
},
created() {
this.getList();
},
methods: {
handleClick(row) {
console.log(row);
getList(){
axios.get("/xy/data/list").then(Response=>{
this.queueList = Response.data
})
}
},
Expand Down

0 comments on commit c7e53fb

Please sign in to comment.