1

我正在使用拆分器拆分消息并将其传递到相应的其他通道以进行进一步处理。

但我想将分离器输出发送到一个通道,该通道会将其写入另一个文件。还想将分离器输出发送到另一个将执行某些任务的通道。

我可以使用下面的方法来做同样的事情,但如果无法处理通道 2 中的任何拆分记录,它似乎不起作用。它停止该过程并且不在通道1中写入剩余记录。

    <int:splitter input-channel="inputchannel" ref="splitter" method="doSplit" output-channel="routingChannel"/>

   <int-recipient-list-router id="customRouter" input-channel="routingChannel"
      <int:recipient channel="channel1"/> <!--Write to file-->
      <int:recipient channel="channel2"/> <!-- logic to process -->
   </int:reciepient-list-router>

有没有其他方法可以独立地将它传递给单独的通道。

4

1 回答 1

1

recipient-list-router一个选项,如:

/**
 * Specify whether send failures for one or more of the recipients should be ignored. By default this is
 * <code>false</code> meaning that an Exception will be thrown whenever a send fails. To override this and suppress
 * Exceptions, set the value to <code>true</code>.
 * @param ignoreSendFailures true to ignore send failures.
 */
public void setIgnoreSendFailures(boolean ignoreSendFailures) {

或者,如果您希望 XML 配置:

<xsd:attribute name="ignore-send-failures">
        <xsd:annotation>
            <xsd:documentation><![CDATA[
                If set to "true", failures to send to a message channel will
                be ignored. If set to "false", a MessageDeliveryException will be
                thrown instead, and if the router resolves more than one channel,
                any subsequent channels will not receive the message.

                Please be aware that when using direct channels (single threaded),
                send-failures can be caused by exceptions thrown by components
                much further down-stream.

                This attribute defaults to false.
            ]]></xsd:documentation>
        </xsd:annotation>
        <xsd:simpleType>
            <xsd:union memberTypes="xsd:boolean xsd:string" />
        </xsd:simpleType>
    </xsd:attribute>
于 2017-05-25T17:45:44.880 回答