Spring 分配器输出到多个通道

Spring Splitter output to multiple channels

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

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

我可以使用下面的方法来做同样的事情,但如果未能处理通道 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>

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

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>