1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.dy.rtuMw.server.msCenter;
 
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
/**
 * @Author: liurunyu
 * @Date: 2025/2/12 15:35
 * @Description
 */
//使起作用,本类注解@Component,并在PipIrrMwRtuApplication注解@EnableScheduling
@Component
public class TestMsResource {
 
    // 设置定时十秒一次
    @Scheduled(cron = "0/1 * * * * ?")
    public void WsHeartBeat() throws Exception {
        MsObj obj = new MsObj() ;
        obj.put("id", System.currentTimeMillis());
        obj.put("ms", "消息" + System.currentTimeMillis());
        MsCenterUnit.getInstance().pushMs(obj);
    }
 
}