1

複数の構成ファイルを持つ Spring Integration アプリケーションがあり、各構成ファイルは JMS キューに接続されています。すべてのキューが単一のチャネル [requestChannel] にメッセージを送信します。この共通情報を common.xml ファイルに保持しています。

メッセージを JMS キューに送信すると、1 つのキューのみがメッセージ requestChannel を送信し、残りのキューはメッセージを宛先 [requestChannel] に送信しません。

誰かが私が間違っていることを提案できますか?

2 つの異なるファイルで同じ変数名を使用し、それらを 1 つのメイン Conext ファイルで呼び出すことはできますか? [MainApplicationContext.xml]、現在、これを行っています。

MainApplicationContext.xml ファイル -- 他のすべての構成ファイルを呼び出します。

<beans>
<import resource="common.xml"/> 
<import resource="config1.xml"/> 
<import resource="config2.xml"/>
<import resource="config3.xml"/>
</beans>

Common.xml -- 共通のチャネルの詳細があります

<bean>
<int:channel id="requestChannel" />

<bean id="testBean" class="com.TestBean" />

<int:chain input-channel="requestChannel">
    <int:service-activator ref="testBean" method="processor"/>
</int:chain>    

<int:channel id="errorChannel" />
<bean id="epBean" class="com.ErrorProcessorBean" />

<int:chain input-channel="errorChannel">
    <int:service-activator ref="epBean" method="processor"/>
</int:chain>    

</bean>

config1.xml -- JMS キュー 1

<beans>

    <int-jms:message-driven-channel-adapter
    id="jmsInputQueueAdaptor_au"  channel="requestChannel" connection-factory="cf_au"  destination="InputQueueOne"
    error-channel="errorChannel" />

    <jee:jndi-lookup id="cf_au" jndi-name="jms/ConnectionFactory">  
    </jee:jndi-lookup>

    <jee:jndi-lookup id="InputQueueOne" jndi-name="jms/InputQueueOne">      
    </jee:jndi-lookup>

</beans>

config2.xml -- JMS キュー 2

<beans>

    <int-jms:message-driven-channel-adapter
    id="jmsInputQueueAdaptor_au"  channel="requestChannel" connection-factory="cf_au"  destination="InputQueueOne"
    error-channel="errorChannel" />

    <jee:jndi-lookup id="cf_au" jndi-name="jms/ConnectionFactory">  
    </jee:jndi-lookup>

    <jee:jndi-lookup id="InputQueueTwo" jndi-name="jms/InputQueueTwo">      
    </jee:jndi-lookup>

</beans>
4

1 に答える 1

4

Bean ID は、Bean コンテキスト内で一意である必要があります。親子関係を持つ複数のコンテキストを作成する方法はいくつかありますが、これはあなたが期待していたものかもしれませんが、「インポート」ではそれができません。したがって、config2.xml で定義された id="jsmInputQueueAdapter_au" を持つ Bean は、config1.xml で定義された ID を持つ以前の Bean を置き換えます。

また、あなたの例では、両方の Bean に、destination="InputQueueOne" を含む同じ属性があります。

更新: Bean コンテキストの親子階層を作成する例として、 Spring コンテキスト階層を参照してください。

于 2013-10-14T20:40:45.470 に答える