0
votes

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>

I want to 5 subscribers have to be executed at once or have to be rollback if one subscribe throws any exception. But I can't find the way to sovle.

related article: Pub-Sub error handling strategy

I already asked with the the eip pattern pic and Gary helped. but, I stucked. (Spring Integration : How to guarantee the transaction two more jdbc-outbound-gateway?)

1

1 Answers

0
votes

Since transaction is bounded to the Thread, you should be sure that all your subscribers are withing the same direct flow. In this case they will be invoked one by one.

However I see that you use ignore-failures = "false". Having you ignore all downstream exception and allow for your subscribers to do their work. Although you lose TX rollback, of course.

So, revise your use-case if you really want to have automatic rallback.

There is an async trick to control TX, but it is a bit complex and require some logic with aggregator.