diff --git a/axhub-gateway/src/main/java/io/shinhanlife/axhub/biz/mcp/gateway/presentation/McpRouterController.java b/axhub-gateway/src/main/java/io/shinhanlife/axhub/biz/mcp/gateway/presentation/McpRouterController.java index 7a2b52a..35e62a3 100644 --- a/axhub-gateway/src/main/java/io/shinhanlife/axhub/biz/mcp/gateway/presentation/McpRouterController.java +++ b/axhub-gateway/src/main/java/io/shinhanlife/axhub/biz/mcp/gateway/presentation/McpRouterController.java @@ -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)을 통해 레거시 툴을 호출합니다.") diff --git a/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/tool/service/AbstractMcpToolService.java b/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/tool/service/AbstractMcpToolService.java index 7f49e84..64d4a56 100644 --- a/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/tool/service/AbstractMcpToolService.java +++ b/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/tool/service/AbstractMcpToolService.java @@ -34,10 +34,14 @@ public abstract class AbstractMcpToolService { @Autowired protected ObjectMapper objectMapper; - /** - * 레거시 시스템을 호출하고 공통 처리(PII 마스킹 등)를 수행합니다. - */ protected Map executeLegacy(String routingType, String interfaceId, Object inputData) { + return executeLegacy(routingType, interfaceId, inputData, null); + } + + /** + * 레거시 시스템을 호출하고 공통 처리(PII 마스킹 등)를 수행합니다. (스펙 지정 가능) + */ + protected Map executeLegacy(String routingType, String interfaceId, Object inputData, java.util.List> spec) { Map 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] 레거시 시스템 통신 완료"); diff --git a/axhub-tool-other/src/main/java/io/shinhanlife/axhub/biz/mcp/tool/service/SampleStringToolService.java b/axhub-tool-other/src/main/java/io/shinhanlife/axhub/biz/mcp/tool/service/SampleStringToolService.java index b577af6..d3c3fba 100644 --- a/axhub-tool-other/src/main/java/io/shinhanlife/axhub/biz/mcp/tool/service/SampleStringToolService.java +++ b/axhub-tool-other/src/main/java/io/shinhanlife/axhub/biz/mcp/tool/service/SampleStringToolService.java @@ -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 result = executeLegacy("MCI_STRING", "TRGM_001", req); + // 스펙에 mciFormat = STRING 힌트를 주어 전문 통신으로 자동 분기되게 합니다. + java.util.List> spec = java.util.List.of( + Map.of("mciFormat", "STRING") + ); + Map result = executeLegacy("MCI", "TRGM_001", req, spec); if (!"SUCCESS".equals(result.get("status"))) { return result;