Spring集成:如何在一个事务中处理多个订阅服务器?

时间:2014-10-27 02:42:51

标签: spring-integration

My Spring Integration Xml。

<int:channel id="request-write-to-PMSQueueChannel" >
    <int:queue message-store="channelStore" />
</int:channel>
<int:bridge input-channel="request-write-to-PMSQueueChannel" output-channel="writetoPMSChannel">
    <int:poller fixed-rate="5000" max-messages-per-poll="-1">
       <int:transactional propagation="REQUIRED" transaction-manager="transactionManager"/>
    </int:poller>
</int:bridge>   
<int:channel id="redBlue-error-channel"/>
<int:service-activator id="errorServiceActivator" input-channel ="redBlue-error-channel">
                <bean id="errorSVC"
            class="com.sds.redBlue.core.module.analyzer.sample.ErrorServiceActivator"/>
</int:service-activator>
<bean id="channelStore" class="org.springframework.integration.jdbc.store.JdbcChannelMessageStore">
    <property name="dataSource" ref="dataSource" />
    <property name="channelMessageStoreQueryProvider" ref="queryProvider" />
</bean>
<bean id="queryProvider" class="org.springframework.integration.jdbc.store.channel.DerbyChannelMessageStoreQueryProvider"/>
<int:publish-subscribe-channel id="writetoPMSChannel" ignore-failures = "false"/>

<int:chain input-channel="writetoPMSChannel"
    output-channel="writetoPMS001Channel">
    <int:service-activator method="exectue">
        <bean id=""
            class="com.sds.redBlue.core.module.analyzer.convert.ModelingConvertSVC">
        </bean>
    </int:service-activator>
    <int:splitter ref="fromListToRowSplitter" />
</int:chain>

<int:chain input-channel="writetoPMSChannel"
    output-channel="writetoPMS002Channel">
    <int:service-activator method="exectue002">
        <bean id=""
            class="com.sds.redBlue.core.module.analyzer.convert.ModelingConvertSVC">
        </bean>
    </int:service-activator>
    <int:splitter ref="fromListToRowSplitter" />
</int:chain>

<int:chain input-channel="writetoPMSChannel"
    output-channel="writetoPMS003Channel">
    <int:service-activator method="exectue003">
        <bean id=""
            class="com.sds.redBlue.core.module.analyzer.convert.ModelingConvertSVC">
        </bean>
    </int:service-activator>
    <int:splitter ref="fromListToRowSplitter" />
</int:chain>

<int:chain input-channel="writetoPMSChannel"
    output-channel="writetoPMS004Channel">
    <int:service-activator method="exectue004">
        <bean id=""
            class="com.sds.redBlue.core.module.analyzer.convert.ModelingConvertSVC">
        </bean>
    </int:service-activator>
    <int:splitter ref="fromListToRowSplitter" />
</int:chain>

<int:chain input-channel="writetoPMSChannel"
    output-channel="writetoPMS005Channel">
    <int:service-activator method="exectue005">
        <bean id=""
            class="com.sds.redBlue.core.module.analyzer.convert.ModelingConvertSVC">
        </bean>
    </int:service-activator>
    <int:splitter ref="fromListToRowSplitter" />
</int:chain>

我想要一次执行5个订阅者,或者如果一个订阅者抛出任何异常,则必须回滚。但我无法找到解决方法。

相关文章: Pub-Sub error handling strategy

我已经问过eip模式pic和Gary的帮助。但是,我坚持了下来。 (Spring Integration : How to guarantee the transaction two more jdbc-outbound-gateway?

1 个答案:

答案 0 :(得分:0)

由于事务受限于线程,因此您应该确保所有订阅者都使用相同的直接流。在这种情况下,它们将被逐个调用。

但是我看到你使用ignore-failures = "false"。让您忽略所有下游异常并允许您的订阅者完成他们的工作。虽然你丢失了TX回滚,但当然。

所以,如果你真的想要自动rallback,请修改你的用例。

有一个async技巧来控制TX,但它有点复杂,需要一些aggregator的逻辑。