chore: 【ops】队列同步JOB
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.viewsh.module.ops.framework.job.queue;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.viewsh.framework.tenant.core.job.TenantJob;
|
||||
import com.viewsh.module.ops.service.queue.QueueSyncService;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 队列同步 Job
|
||||
* 定时将 MySQL 数据同步到 Redis
|
||||
*
|
||||
* @author lzh
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class QueueSyncJob {
|
||||
|
||||
@Resource
|
||||
private QueueSyncService queueSyncService;
|
||||
|
||||
/**
|
||||
* 定时同步任务:将最近1小时内变更的数据同步到 Redis
|
||||
* 建议在 xxl-job 管理平台配置为每5分钟执行一次:
|
||||
*
|
||||
* @return 同步结果
|
||||
*/
|
||||
@XxlJob("queueSyncJob")
|
||||
@TenantJob // 多租户
|
||||
public String execute() {
|
||||
try {
|
||||
queueSyncService.syncMySQLToRedis();
|
||||
return "队列同步任务执行成功";
|
||||
} catch (Exception e) {
|
||||
log.error("队列同步任务执行失败", e);
|
||||
return StrUtil.format("队列同步任务执行失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user