【问题标题】:spring-integration poller synchronization-factory in advice-chain建议链中的弹簧集成轮询器同步工厂
【发布时间】:2015-03-12 10:00:01
【问题描述】:

我的目标是让弹簧集成轮询器在发生多个异常时退出轮询。

我配置了以下出站通道适配器

    <int:outbound-channel-adapter id="adapter" ref="handler" 
        method="handle" channel="channel" >
        <int:poller max-messages-per-poll="50" fixed-delay="13"
             time-unit="SECONDS" task-executor="threadpool">
            <int:transactional synchronization-factory="mySyncFactory" 
                transaction-manager="simpleJdbcTransactionManager"
                timeout="30"/>
        </int:poller>   
    </int:outbound-channel-adapter>

现在我想添加另一个建议(电路断路器)。为此,我必须删除 int:transactional-tag 并添加一个建议链。我可以这样写

    <int:outbound-channel-adapter id="adapter" ref="handler" 
        method="handle" channel="channel" >
        <int:poller max-messages-per-poll="50" fixed-delay="13"
             time-unit="SECONDS" task-executor="threadpool">
            <int:advice-chain>
                <tx:advice transaction-manager="simpleJdbcTransactionManager">
                    <tx:attributes>
                        <tx:method name="*" timeout="30000" />
                    </tx:attributes>
                </tx:advice>
                <int:ref bean="cuircuitBreaker"/>
            </int:advice-chain>
        </int:poller>   
    </int:outbound-channel-adapter>

我找不到为 tx-advice 声明同步工厂的可能性。关于如何实现这一点的任何提示?

更新 我正在使用弹簧集成版本 3.0.4

【问题讨论】:

    标签: spring spring-integration


    【解决方案1】:

    您似乎错过了 &lt;int:advice-chain&gt; 具有相同的 synchronization-factory 属性并且完全出于相同的目的。

    及其描述:

    仅当链中存在事务通知时,此属性的设置才会产生影响。

    【讨论】:

    • &lt;tx:advice&gt; 不在 Spring Integration 范围内,因此我们无权访问该组件,应该只为父标签提供该解决方案。由于&lt;transactional&gt;&lt;advice-chain&gt; 是互斥的,所以synchronization-factoryadvice-chain 上看起来很直观,但在其他地方却没有。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-24
    • 1970-01-01
    • 2017-09-02
    • 1970-01-01
    相关资源
    最近更新 更多