我有下一个配置:
入站
<int:gateway id="inGateway" service-interface="XXX"
error-channel="errorChannel"
default-request-channel="requestChannel"
default-reply-channel="replyChannel" />
出站:
<ws:outbound-gateway id="ws-outbound-gateway"
request-channel="inbound" reply-channel="outbound" uri="XXX" />
链1:
<int:chain input-channel="requestChannel" output-channel="inbound">
XXX </int:chain>
链2:
<int:chain input-channel="outbound" output-channel="replyChannel"> XXX
</int:chain>
错误:
<int:chain input-channel="errorChannel" output-channel="replyChannel">
<int:transformer ref="logicTransformers" method="errorTransformerMethod"></int:transformer>
</int:chain>
</beans>
Java Transformer:
final GenericError errorCatalog = errorCatalog(errorMessage);
LOGGER.warn("Transformed error from catalog: {}", errorCatalog);
final MessageBuilder<Document> builder =
MessageBuilder.withPayload(XmlUtil.parseToDocument(errorCatalog)).copyHeaders(errorMessage.getHeaders()).copyHeadersIfAbsent(errorMessage.getHeaders());
当出站的web服务停止时,错误进入errorChannel转换器,但要响应,我们有下一个错误:
osmcGenericMessagingTemplate $ TemporaryReplyChannel#242收到回复消息但接收线程在发送请求消息时因异常而退出:GenericMessage [payload = [#document:null],headers = {spanTraceId = 8bf90ea9ff4266c8,spanId = 598680bae5f913d5,spanParentSpanId = 8bf90ea9ff4266c8,replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@76c751de,functionalId = PRUEBASOA12,errorChannel = land.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@76c751de,messageSent = true,id = 2108386f-99db-98b9- 3d30-3bcf45335424,spanSampled = 1,spanName = message:requestChannel}]
我们不明白......因为我们有相同的流程
1 回答
如果服务级别出现错误,原始消息将被包装到
MessagingException
,ErrorMessage
将payload
发送到errorChannel
. 即使您明确使用replyChannel
,仍然必须确保replyChannel
标头,该标头由入站网关填充 . 确切地说,此标头在该网关中的请求 - 回复行为中起主要作用 .replyHeader
仍然存在于您的错误流中,但它已经是MessagingException
有效负载中failedMessage
的一部分 .因此,您的
logicTransformers.errorTransformerMethod
应该从该方法中提取replyChannel
标头,以便将此方法发送到显式replyChannel
. 或者你可以省略这个replyChannel
,因为真正的sendAndReceive
基于replyChannel
标头 .请阅读参考手册中的更多信息:
https://docs.spring.io/spring-integration/docs/4.3.11.RELEASE/reference/html/messaging-endpoints-chapter.html#gateway
https://docs.spring.io/spring-integration/docs/4.3.11.RELEASE/reference/html/configuration.html#namespace-errorhandler