Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring integration int jms:消息驱动的通道适配器和确认=";交易;_Spring Integration - Fatal编程技术网

Spring integration int jms:消息驱动的通道适配器和确认=";交易;

Spring integration int jms:消息驱动的通道适配器和确认=";交易;,spring-integration,Spring Integration,我有一个消息驱动的通道适配器,配置为从队列中拾取消息,并将确认设置为Transact。是否可以将不同的消息发送到下游持有相同事务的不同队列,并且在流中的不同队列之间也有数据库插入?。如果消息传递到任何队列失败,则事务必须回滚(包括数据库条目)并将消息发送到其他队列 示例:队列(接收)--->插入数据库-->发送到(队列1、队列2..etc向每个队列发送不同的消息) 如果队列1、队列2等的任何发送调用失败,则事务应回滚 我可以使用单个队列进行配置(即仅使用队列1)。但是,如果涉及多个队列并保持事务

我有一个消息驱动的通道适配器,配置为从队列中拾取消息,并将确认设置为Transact。是否可以将不同的消息发送到下游持有相同事务的不同队列,并且在流中的不同队列之间也有数据库插入?。如果消息传递到任何队列失败,则事务必须回滚(包括数据库条目)并将消息发送到其他队列

示例:队列(接收)--->插入数据库-->发送到(队列1、队列2..etc向每个队列发送不同的消息)

如果队列1、队列2等的任何发送调用失败,则事务应回滚

我可以使用单个队列进行配置(即仅使用队列1)。但是,如果涉及多个队列并保持事务边界,该怎么办呢

谢谢 维迪亚

下面是配置

                                                              <int-jms:message-driven-channel-adapter
    id="MessageDrivenAdapter" channel="injmsChannel" destination="testQ"
    concurrent-consumers="5" max-concurrent-consumers="10" acknowledge="transacted"
    error-channel="Error" />

<int:channel id="injmsChannel" />

<int:chain input-channel="injmsChannel" id="Chain1">


    <int-jpa:retrieving-outbound-gateway
        entity-class="entity.TestTable8"
        entity-manager-factory="entityManagerFactory" id-expression="payload.getSno()">
        <int-jpa:transactional transaction-manager="transactionManager" />
    </int-jpa:retrieving-outbound-gateway>

    <int:recipient-list-router id="ROUTE_1_2">
        <int:recipient channel="SuccessChannel"
            selector-expression="payload.getSno()==1" />
            /> -->
    </int:recipient-list-router>

</int:chain>

<int:channel id="SuccessChannel" />


<int:chain id="MessageProcessingChain" input-channel="SuccessChannel"
    output-channel="putMsgChannel">

    <int:service-activator id="a1" ref="taskexe"
        method="processTable8_1" requires-reply="true" />

    <int-jpa:retrieving-outbound-gateway
        id="table7" entity-class="entity.TestTable7"
        entity-manager-factory="entityManagerFactory" id-expression="payload.getSno()">
        <int-jpa:transactional transaction-manager="transactionManager" />
    </int-jpa:retrieving-outbound-gateway>

    <int:service-activator id="a2" ref="taskexe"
        method="processTable8_2" requires-reply="true" />

    <int-jpa:updating-outbound-gateway
        id="table6" entity-class="entity.TestTable6"
        entity-manager-factory="entityManagerFactory" flush="true">
        <int-jpa:transactional transaction-manager="transactionManager" />
    </int-jpa:updating-outbound-gateway>

    <int:service-activator id="a3" ref="taskexe"
        method="processTable6_1" requires-reply="true" />

    <int-jpa:updating-outbound-gateway
        id="uptable6" entity-class="entity.TestTable6"
        entity-manager-factory="entityManagerFactory" flush="true">
        <int-jpa:transactional transaction-manager="transactionManager" />
    </int-jpa:updating-outbound-gateway>

    <int:service-activator id="a4" ref="taskexe"
        method="processTable6_2" requires-reply="true" />



    <int-jpa:updating-outbound-gateway
        id="uptable4" entity-class="entity.TestTable4"
        entity-manager-factory="entityManagerFactory" flush="true">
        <int-jpa:transactional transaction-manager="transactionManager" />
    </int-jpa:updating-outbound-gateway>



    <int:service-activator ref="taskexe" method="processTable4_1"
        requires-reply="true" />



</int:chain>

<int:channel id="putMsgChannel" />

<int-jms:outbound-channel-adapter id="sendsomemsg"
    channel="putMsgChannel" connection-factory="connectionFactory"
    session-transacted="true" destination-expression="headers['somequeue']" />

/> -->

如何为具有消息驱动适配器相同事务边界的其他队列添加另一个int-jms:outbound-channel-adapte?。此外,还设置了flush=true,以便在出现任何jpa适配器异常时,不会向下游传递消息

只要使用
JmsTemplate
(包括使用JMS出站通道适配器)在同一线程上执行队列发送,它们将在与消息驱动适配器的消息传递相同的事务会话中执行

如果将JDBC事务管理器添加到消息驱动适配器,其事务将与JMS事务同步

这提供了中讨论的“尽最大努力1便士”


DB提交成功而JMS提交失败的可能性很小,因此您需要处理重复项。为了避免您需要完整的XA解决方案。

这里的主持人不允许您编辑我的答案,并提供有关您问题的更多详细信息;您需要编辑您的问题(并对我的答案发表评论,以便我收到通知)。但是,我可以看到您的编辑,它没有包含足够的信息来进一步帮助您-您需要显示所有配置,包括消息驱动适配器。