feat: 增强多实例分布式部署兼容
- 增加定时任务分布式锁并覆盖 chatlog、文档导入和 Agent HITL 过期扫描 - 增强 Redis MQ 多实例 consumer 标识、pending reclaim 和单条处理能力 - 增加文档导入状态 Redis 广播和 Agent HITL 跨节点路由确认
This commit is contained in:
@@ -4,19 +4,33 @@ import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import tech.easyflow.chatlog.config.ChatSyncProperties;
|
||||
import tech.easyflow.chatlog.service.ChatSyncService;
|
||||
import tech.easyflow.common.cache.DistributedScheduledLock;
|
||||
|
||||
/**
|
||||
* 聊天记录同步定时任务。
|
||||
*/
|
||||
@Component
|
||||
public class ChatSyncScheduler {
|
||||
|
||||
private final ChatSyncService chatSyncService;
|
||||
private final ChatSyncProperties syncProperties;
|
||||
|
||||
/**
|
||||
* 创建聊天记录同步定时任务。
|
||||
*
|
||||
* @param chatSyncService 聊天同步服务
|
||||
* @param syncProperties 同步配置
|
||||
*/
|
||||
public ChatSyncScheduler(ChatSyncService chatSyncService, ChatSyncProperties syncProperties) {
|
||||
this.chatSyncService = chatSyncService;
|
||||
this.syncProperties = syncProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步聊天会话摘要。
|
||||
*/
|
||||
@Scheduled(fixedDelayString = "${easyflow.chat.sync.fixed-delay:30000}", initialDelay = 10000L)
|
||||
@DistributedScheduledLock(key = "easyflow:schedule:chat-sync:sessions", leaseSeconds = 300L)
|
||||
public void syncSessions() {
|
||||
if (!syncProperties.isEnabled()) {
|
||||
return;
|
||||
@@ -24,7 +38,11 @@ public class ChatSyncScheduler {
|
||||
chatSyncService.syncSessions();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步聊天日志明细。
|
||||
*/
|
||||
@Scheduled(fixedDelayString = "${easyflow.chat.sync.fixed-delay:30000}", initialDelay = 15000L)
|
||||
@DistributedScheduledLock(key = "easyflow:schedule:chat-sync:logs", leaseSeconds = 300L)
|
||||
public void syncLogs() {
|
||||
if (!syncProperties.isEnabled()) {
|
||||
return;
|
||||
@@ -32,7 +50,11 @@ public class ChatSyncScheduler {
|
||||
chatSyncService.syncLogs();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修复近期聊天日志同步缺口。
|
||||
*/
|
||||
@Scheduled(cron = "0 15 3 * * *")
|
||||
@DistributedScheduledLock(key = "easyflow:schedule:chat-sync:repair-logs", leaseSeconds = 300L)
|
||||
public void repairLogs() {
|
||||
if (!syncProperties.isEnabled()) {
|
||||
return;
|
||||
@@ -40,7 +62,11 @@ public class ChatSyncScheduler {
|
||||
chatSyncService.repairLogs();
|
||||
}
|
||||
|
||||
/**
|
||||
* 维护聊天日志 MySQL 分表。
|
||||
*/
|
||||
@Scheduled(cron = "0 0 2 * * *")
|
||||
@DistributedScheduledLock(key = "easyflow:schedule:chat-sync:maintain-mysql-tables", leaseSeconds = 300L)
|
||||
public void maintainMysqlTables() {
|
||||
chatSyncService.maintainMysqlTables();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user