2016-04-25 13 views
2

私は、アクノリッジがトランザクションに設定されたキューからメッセージを選択するように構成されたメッセージ駆動型のチャネルアダプタを持っています。別のキューに異なるメッセージを送信することも可能ですか?同じトランザクションを保持しているストリームは、フロー内にデータベースを挿入しますか?メッセージ配信がいずれのキューにも失敗した場合、トランザクションはロールバックされ(データベースエントリを含む)、メッセージは他のキューに送信されなければなりません。int-jms:メッセージドリブンチャネルアダプタとアクノリッジ= "トランザクション"

例:キュー(受信)---> DBの挿入 - >(各キューに異なるメッセージを送るQUEUE1、キュー2 ...など)に送信

を任意の送信呼び出しがQUEUE1のために失敗した場合、キュー2などトランザクションはロールバックする必要があります。

私は単一のキュー(つまり、queue1のみ)で構成できます。しかし、複数のキューが関与し、トランザクション境界を保持している場合はどうすればよいですか。

おかげ Vaidya

以下

は別のint-JMSを追加する方法を設定

               <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']" /> 

次のとおりです。メッセージ駆動アダプタの同じトランザクション境界を持つ他のキューのためのアウトバウンド・チャネルadapte?。また、jpaアダプターの例外があれば、メッセージがダウンストリームに渡されないように、flush = trueが設定されています。

答えて

1

JmsTemplate(JMS送信チャネルアダプタの使用を含む)を使用してキューの送信が実行される限り、同じスレッド上では、メッセージ駆動型アダプタのメッセージ配信と同じトランザクションセッションで実行されます。

JDBCトランザクションマネージャをメッセージドリブンアダプタに追加すると、そのトランザクションはJMSトランザクションと同期されます。

Dave Syer's JavaWorld article: Distributed transactions in Spring, with and without XAで説明されているように、これは「ベストエフォート1PC」を提供します。

DBコミットが成功し、JMSコミットが失敗する可能性が低いため、重複を処理する必要があります。これを回避するには、完全なXAソリューションが必要です。

+0

ここの司会者はあなたの質問の詳細について私の回答を編集することはできません。代わりにあなたの質問を編集する必要があります(そして私の答えにコメントをつけて通知を受ける必要があります)。しかし、私はあなたの編集を見ることができ、それ以上の助けになるほどの情報が含まれていません - メッセージ駆動型アダプターを含むすべての構成を表示する必要があります。 –

関連する問題