From 3ec2579c7748db85c8e62ecc7427d340680f4f67 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 10 Jan 2023 15:01:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20WebSocket=E5=A2=9E=E5=8A=A0=E5=AE=9A=E6=97=B6=E5=BF=83?= =?UTF-8?q?=E8=B7=B3=E6=A3=80=E6=9F=A5=E9=98=B2=E6=AD=A2=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1018491 --user=赵勇 【接口测试】github#18046,接口自动化,在导入的接口,配置“前置操作--等待控制器”时间设置为5分钟,“调试”接口最后没显示执行结果 https://www.tapd.cn/55049933/s/1325162 --- .../io/metersphere/websocket/IndexWebSocket.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/websocket/IndexWebSocket.java b/api-test/backend/src/main/java/io/metersphere/websocket/IndexWebSocket.java index 15b4419fb1..25f695d156 100644 --- a/api-test/backend/src/main/java/io/metersphere/websocket/IndexWebSocket.java +++ b/api-test/backend/src/main/java/io/metersphere/websocket/IndexWebSocket.java @@ -1,10 +1,11 @@ package io.metersphere.websocket; -import io.metersphere.commons.utils.JSON; -import io.metersphere.utils.LoggerUtil; import io.metersphere.api.dto.MsgDTO; +import io.metersphere.commons.utils.JSON; import io.metersphere.commons.utils.WebSocketUtil; +import io.metersphere.utils.LoggerUtil; import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.websocket.*; @@ -60,4 +61,12 @@ public class IndexWebSocket { public void onError(Session session, Throwable throwable) throws IOException { session.close(); } + + /** + * 每一分钟群发一次心跳检查 + */ + @Scheduled(cron = "0 0/1 * * * ?") + public void heartbeatCheck() { + WebSocketUtil.sendMessageAll("heartbeat check"); + } }