SI (Spring Integration)가 SI 도메인 아래의 예외를 MessageException 인스턴스로 래핑하고 "오류 채널 ". 다음스프링 통합 : 오류 채널에서 응답 메시지가 클라이언트에 전송되지 않음
내 스프링 설정 파일에서 몇 조각입니다 : 클라이언트가 어떤 inturn 위의 스프링 설정 파일에 정의 된 게이트웨이에서 수신 된 요청을 배치 내 구현 클래스에 REST 호출을
<int:channel-interceptor pattern="ersServiceReqRcvPostValidationChannel,ersServiceResRcvPostValidationChannel" order="1">
<bean class="com.bnym.ecs.report.service.orchestration.interceptors.MsgJSONSyntaxValidationInterceptor"/>
</int:channel-interceptor>
<int:channel-interceptor pattern="ersServiceReqRcvPostValidationChannel,ersServiceResRcvPostValidationChannel" order="2">
<bean class="com.bnym.ecs.report.service.orchestration.interceptors.MsgMetaDataValidationInterceptor"/>
</int:channel-interceptor>
<!-- Gateways -->
<int:gateway id="ersServiceReqRcvGateway"
service-interface="com.bnym.ecs.report.service.orchestration.gateway.ERSOrchestrationSvcReqGateway"
error-channel="reqRcvExceptionHandlerChannel">
<int:method name="processRequest" request-channel="ersServiceReqRcvPostValidationChannel" />
</int:gateway>
<!-- Chain to handle all incoming request *after* doing all validations -->
<int:chain input-channel="ersServiceReqRcvPostValidationChannel">
<int:service-activator ref="msgReqAuditDetailDAOIntegrator" method="persist" />
<!-- Router -->
<int:router ref="ersServiceReqRcvRouter" />
</int:chain>
<!-- 6) Pass the message through ERS svc to Exec svc ADH chain - Chain2 -->
<int:chain input-channel="ersSvc2execSvcQMRChannel" output-channel="ersServiceResRcvPostValidationChannel">
<int:transformer ref="json2ObjTransformer" method="transformToERSOrchestrationSvcReq" />
<int:service-activator ref="executionSvcReqMsgBuilder" method="getRptExecutionSvcReqForDataEngine" />
<int:transformer ref="obj2JsonTransformer" method="transformFromRptExecutionSvcReqForDataEngine" />
<int:service-activator ref="msgReqAuditDAOIntegrator" method="persist" />
<int:service-activator ref="msgReqAuditDetailDAOIntegrator" method="persist" />
<int:service-activator ref="executionSvcRESTStub" method="executeReportJSON" />
</int:chain>
<int:chain input-channel="reqRcvExceptionHandlerChannel">
<int:transformer ref="exceptionTransformer" method="handleError"/>
</int:chain>
@Path("/reportExecutor")
public class ERSOrchestrationServiceImpl {
@Autowired
private ReportInstanceDAO reportInstanceDAO;
private static final ERSOrchestrationSvcDiagnosticLogger _logger =
ERSOrchestrationSvcDiagnosticLogger.getInstance(ERSOrchestrationServiceImpl.class);
@Context
HttpServletRequest request;
@Context
HttpServletResponse response;
@POST
@Path("/executeOnlineReport")
@Produces({MediaType.APPLICATION_JSON})
public String executeOnlineReport(String jsonRequest) {
ApplicationContext appCtx = SpringApplicationContextUtil.getApplicationContext();
ERSOrchestrationSvcReqGateway ersOrchestrationSvcReqGateway =
(ERSOrchestrationSvcReqGateway) appCtx.getBean("ersServiceReqRcvGateway");
Message<String> inputMsg = MessageBuilder.withPayload(jsonRequest)
.setHeader(ERSServiceConstants.KEY_MSG_CORRELATION_ID, correlationId)
.setHeader(ERSServiceConstants.KEY_MSG_REPORT_INSTANCE_ID, reportInstanceId)
.build();
Message<String> returnMsg = ersOrchestrationSvcReqGateway.processRequest(inputMsg);
return returnMsg.getPayload();
}
위의 스프링 설정 파일에서 언급했듯이 error-channel은 클라이언트에 대해 유효한 실패한 응답 메시지를 생성하고 메시지를 반환하는 Transformer에 의해 읽혀집니다.
public class ErrorMessageUnwrapTransformer {
@Autowired
private Gson gsonUtil;
@Autowired
private ReportInstanceDAO reportInstanceDAO;
@Autowired
private ERSOrchestrationSvcFailedResMsgBuilder executionSvcFailedMsgBuilder;
private static final ERSOrchestrationSvcDiagnosticLogger _log =
ERSOrchestrationSvcDiagnosticLogger.getInstance(ErrorMessageUnwrapTransformer.class);
@Transformer
public Message<?> handleError(Message<?> message) {
try{
failedMsg = ((MessagingException) message.getPayload()).getFailedMessage();
//some code logic to build a valid failed response message goes here
Message<?> failedResponseMsg = executionSvcFailedMsgBuilder.getERSOrcSvcFailedResMsg(failedMsg);
return failedResponseMsg;
}
모든 I 오류 채널에 넣어 예외, 즉, 예외가 MessagingException의로 싸여를 얻을 때 잘 작동하는 것 같다, Transformer는, 수 그것의 failedMessage를, 채널을 읽을 얻을 수있다 유효한 실패한 응답 메시지를 작성하여 리턴하십시오.
그러나 내가 얻는 유일한 문제는 호출자가 호출자에게 돌아 가지 않는다는 것입니다. 즉, 핸들은 처리 흐름을 시작했던 다음 코드로 돌아갈하지 않습니다
Message<String> returnMsg = ersOrchestrationSvcReqGateway.processRequest(inputMsg);
사람이 pls는 메시지에 의해 반환되는 이유를 알려 수있는 오류 채널 읽기 변압기 다시 반환하지 게이트웨이 메소드를 호출 한 클래스에?
나는 동일한 문제에 직면하고있다. 당신은 그의 문제를 해결 했습니까? – vbazaga86