Spring 出站通道适配器中的集成处理程序错误 --> 确认确认通道

Spring integration handler error in outbound-channel-adapter --> confirm-ack-channel

我想做:

  1. 从网络服务接收消息
  2. 发送xml消息给兔子
  3. 将 xml 验证为 xsd --> 启动异常(验证不正确)
  4. Return Web 服务的自定义错误消息

第 1 步:从 Web 服务接收消息 --> 结果正常

<ws:inbound-gateway id="ws-inbound-gateway"
        request-channel="requestChannel" reply-channel="replyChannel" reply-timeout="300000"
        error-channel="errorChannel" />
<int:chain input-channel="requestChannel" output-channel="inbound">
        <int:service-activator ref="defaultLogger" method="logger"/>
</int:chain>

第 2 步:在 fanout exchange rabbit 中写入 xml 消息 --> RESULT OK

<int-amqp:outbound-channel-adapter 
    channel="inbound" amqp-template="amqpTemplate" return-channel="outbound"
    exchange-name="es.queue.test"
    confirm-ack-channel="confirmAck" confirm-nack-channel="confirmNack" confirm-correlation-expression="#this" />

第 3 步:将 xml 验证为 xsd --> 结果正常 XsdValidationException

<int:chain input-channel="confirmAck" output-channel="outbound">
        <int:service-activator ref="defaultLogger" method="logger"/>
        <int-xml:validating-filter schema-type="xml-schema"
            schema-location="classpath:/schema/prueba.xsd"
            throw-exception-on-rejection="true" discard-channel="errorChannel" />
    </int:chain>

在这一步中,消息将被发送到 errorChannel 但我有下一个错误:

 63863 [AMQP Connection 10.0.9.155:5672] ERROR o.s.a.r.s.PublisherCallbackChannelImpl - Exception delivering confirm 
org.springframework.integration.MessageRejectedException: Message was rejected due to XML Validation errors; nested exception is org.springframework.integration.xml.AggregatedXmlMessageValidationException: Multiple causes:
    cvc-elt.1: No se ha encontrado la declaración del elemento 'ns2:***'.

    at org.springframework.integration.xml.selector.XmlValidatingMessageSelector.accept(XmlValidatingMessageSelector.java:134)
    at org.springframework.integration.filter.MessageFilter.doHandleRequestMessage(MessageFilter.java:161)
    at org.springframework.integration.handler.AbstractReplyProducingPostProcessingMessageHandler.handleRequestMessage(AbstractReplyProducingPostProcessingMessageHandler.java:46)
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:109)

第 4 步:Web 服务客户端从未收到响应 我认为这是错误 "Exception delivering confirm" 发生的原因,因为在尝试发送确认确认时在线程 AMQP 中抛出了异常。

你能帮帮我吗?

一切看起来都不错,除非你向我们解释为什么要使用 throw-exception-on-rejection="true" 并中断流量?

我什至认为 confirm-correlation-expression="#this" 确实将 requestMessage 传递给 confirm-ack-channel,因此您可以从该子流将回复发送回 WS 网关。

但是!由于您 throw-exception-on-rejection="true" 不会向 outbound 频道发送任何内容。

return-channel不予回复。这是另一个错误状态,当 Broker 由于配置错误而无法将消息传递到队列时:http://www.rabbitmq.com/blog/2011/02/10/introducing-publisher-confirms/