【问题标题】:Spring integration handler error in outbound-channel-adapter --> confirm-ack-channel出站通道适配器中的 Spring 集成处理程序错误 --> 确认确认通道
【发布时间】:2017-07-26 14:04:56
【问题描述】:

我想做:

  1. 从网络服务接收消息
  2. 发送xml消息给兔子
  3. 验证 xml 到 xsd --> 启动异常(验证不正确)
  4. 将自定义错误消息返回到 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>

第二步:在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 --> 结果 ok 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 服务客户端永远不会收到响应 我认为这是因为尝试发送确认确认时在线程 AMQP 中抛出异常,所以出现“异常传递确认”错误。

你能帮帮我吗?

【问题讨论】:

    标签: spring-integration amqp spring-amqp


    【解决方案1】:

    一切看起来都不错,除非您向我们解释为什么要使用 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/

    【讨论】:

      猜你喜欢
      • 2015-07-11
      • 2017-12-10
      • 2014-10-23
      • 1970-01-01
      • 2023-03-21
      • 1970-01-01
      • 2014-12-07
      • 2013-02-02
      • 1970-01-01
      相关资源
      最近更新 更多