package com.sikey.wa04.api.message.scheduler;

import com.sikey.wa04.business.application.service.message.MessagingPublishService;
import com.sikey.wa04.business.infrastructure.aop.Tracer;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.Instant;
import java.time.temporal.ChronoUnit;

/**
 * 离线消息加载调度器
 *
 * @author luoyangwei
 */
@Slf4j
@Component
public class OfflineMessageLoadingScheduler {

    @Resource
    private MessagingPublishService messagingPublishService;

    @Tracer
    @Scheduled(cron = "0/3 * * * * ?")
    public void run() {
        //log.info("3秒一次启动推送");
        Instant start = Instant.now();
        messagingPublishService.publishOffline();
        long timeConsuming = ChronoUnit.MILLIS.between(start, Instant.now());
       // log.debug("离线消息加载调度器执行完成，耗时：{} ms", timeConsuming);
    }

}
