package com.sercurityControl.proteam.monitor.controller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** * @author cw chen * @description websocket消息推送 * @date 2023-04-25 10:10 */ @Component //1.主要用于标记配置类,兼备Component的效果。 @EnableScheduling // 2.开启定时任务 public class WebSocketInfoPush { private static final Logger log = LoggerFactory.getLogger(WebSocketInfoPush.class); /** * 创建websocket发送到前端通知事件 * * @param */ @Async("testTaskExecutor") // @Scheduled(cron = "0/60 * * * * ?") public void deviceUpDownToJs() { log.info("发送前端通知"); NoticeWebsocket.sendMessage("来自WebSocket的消息"); } }