begin new project

This commit is contained in:
wangjinlei
2026-04-22 15:55:42 +08:00
commit 5e6bde0862
1370 changed files with 129431 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package com.peanut.modules.springai;
import io.modelcontextprotocol.client.McpSyncClient;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class McpHeartbeatService {
private final List<McpSyncClient> mcpClients;
public McpHeartbeatService(List<McpSyncClient> mcpClients) {
this.mcpClients = mcpClients;
}
@Scheduled(fixedRate = 120000) // 每2分钟1次发送心跳
public void sendHeartbeat() {
try {
this.mcpClients.parallelStream().forEach(client -> {client.ping();});
} catch (Exception e) {
e.printStackTrace();
}
}
}