2013-10-14 3 views
1

각 구성 파일이 JMS 큐에 연결된 다중 구성 파일이있는 Spring Integration 응용 프로그램이 있습니다. 모든 대기열이 단일 채널 [requestChannel]로 메시지를 보내면 common.xml 파일에이 공통 정보가 보관됩니다.여러 개의 구성 파일과의 Spring 통합

JMS 대기열로 메시지를 보낼 때 하나의 대기열 만 requestChannel 메시지를 보내고 나머지 대기열은 [requestChannel] 대상에 메시지를 보내지 않습니다.

Can 누군가 내가 잘못하고있는 것을 제안 할 수 있습니다.

2 개의 다른 파일에서 동일한 varibale 이름을 사용하고 하나의 기본 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는 - 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> 
공통 채널 상세

<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을

답변

4

빈 ID는 빈 내에서 고유해야합니다. 문맥. 부모/자식 관계가있는 여러 컨텍스트를 만드는 방법이 있습니다.이 컨텍스트는 예상했던 것일 수도 있지만 "가져 오기"는 그렇게하지 않습니다. 따라서 config2.xml에 정의 된 id = "jsmInputQueueAdapter_au"가있는 bean은 config1.xml에 정의 된 해당 id를 가진 이전 bean을 대체합니다.

또한 예제에서 두 bean은 destination = "InputQueueOne"을 포함하여 동일한 속성을 갖습니다.

업데이트 : 콩 컨텍스트의 상위 - 하위 계층 구조를 만드는 예를 들어, Spring contexts hierarchy

+0

안녕하세요 당신이 봄에 부모 자식 관계를 가진 여러 구성 파일을 만드는 방법을 자세히 설명해 수를 참조하십시오. –