forked from kimhyungsik/ax_hub_mcp_tool
fix: resolve MCI_STRING routing issue and add fast fail timeout for router
This commit is contained in:
@@ -50,7 +50,13 @@ public class McpRouterController {
|
||||
this.securityProperties = securityProperties;
|
||||
this.objectMapper = objectMapper;
|
||||
this.gatewayFallbackProperties = gatewayFallbackProperties;
|
||||
this.restClient = RestClient.create();
|
||||
|
||||
// [수정됨] 1초 타임아웃을 강제하여 죽은 서버 대기로 인한 지연 방지
|
||||
org.springframework.http.client.SimpleClientHttpRequestFactory factory = new org.springframework.http.client.SimpleClientHttpRequestFactory();
|
||||
factory.setConnectTimeout(1000); // 연결 시도 타임아웃 1초
|
||||
factory.setReadTimeout(1000); // 응답 대기 타임아웃 1초
|
||||
|
||||
this.restClient = RestClient.builder().requestFactory(factory).build();
|
||||
}
|
||||
|
||||
@Operation(summary = "MCP 파이프라인 호출", description = "MCP 표준 파이프라인(ExecuteService)을 통해 레거시 툴을 호출합니다.")
|
||||
|
||||
@@ -34,10 +34,14 @@ public abstract class AbstractMcpToolService {
|
||||
@Autowired
|
||||
protected ObjectMapper objectMapper;
|
||||
|
||||
/**
|
||||
* 레거시 시스템을 호출하고 공통 처리(PII 마스킹 등)를 수행합니다.
|
||||
*/
|
||||
protected Map<String, Object> executeLegacy(String routingType, String interfaceId, Object inputData) {
|
||||
return executeLegacy(routingType, interfaceId, inputData, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 레거시 시스템을 호출하고 공통 처리(PII 마스킹 등)를 수행합니다. (스펙 지정 가능)
|
||||
*/
|
||||
protected Map<String, Object> executeLegacy(String routingType, String interfaceId, Object inputData, java.util.List<Map<String, Object>> spec) {
|
||||
Map<String, Object> inputMap;
|
||||
if (inputData == null) {
|
||||
inputMap = new HashMap<>();
|
||||
@@ -58,7 +62,7 @@ public abstract class AbstractMcpToolService {
|
||||
log.info("=======================================================\n");
|
||||
|
||||
// 1. Adapter 공통 모듈 직접 호출
|
||||
String executionResult = legacyEimsConnector.executeByTool(routingType, interfaceId, inputMap, null);
|
||||
String executionResult = legacyEimsConnector.executeByTool(routingType, interfaceId, inputMap, spec);
|
||||
|
||||
log.info("\n=======================================================");
|
||||
log.info(" [Legacy -> Tool] 레거시 시스템 통신 완료");
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Map;
|
||||
*/
|
||||
@Service
|
||||
@McpTool(
|
||||
routingType = "MCI_STRING",
|
||||
routingType = "MCI",
|
||||
categoryKey = "common"
|
||||
)
|
||||
public class SampleStringToolService extends AbstractMcpToolService {
|
||||
@@ -36,7 +36,11 @@ public class SampleStringToolService extends AbstractMcpToolService {
|
||||
)
|
||||
public Object execute(SampleStringReq req) {
|
||||
// 1. EIMS(Legacy)를 통해 원본 고정 길이 문자열을 받아옵니다.
|
||||
Map<String, Object> result = executeLegacy("MCI_STRING", "TRGM_001", req);
|
||||
// 스펙에 mciFormat = STRING 힌트를 주어 전문 통신으로 자동 분기되게 합니다.
|
||||
java.util.List<Map<String, Object>> spec = java.util.List.of(
|
||||
Map.of("mciFormat", "STRING")
|
||||
);
|
||||
Map<String, Object> result = executeLegacy("MCI", "TRGM_001", req, spec);
|
||||
|
||||
if (!"SUCCESS".equals(result.get("status"))) {
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user