2017-07-26 179 views
0

我想做的事:Spring集成处理程序错误 - >确认 - 确认通道

  1. 从Web服务接收消息
  2. 发送XML消息兔
  3. 验证XML为xsd - >启动异常(验证不正确的)
  4. 返回定制错误消息发送到web服务

步骤1:接收从web服务消息 - > RESULT行

<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:写扇出交换兔一个XML消息 - > RESULT行

<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服务客户端永远不会收到响应 我认为它发生错误“异常发送确认”,因为当尝试发送确认应答时异常抛出线程AMQP。

你能帮我吗?

回答

0

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