1
votes

I have a Spring Integration application with Multiple Configurations files, each configuration files connected to a JMS queue. all queues send message to single channel [requestChannel], I have kept this common information in the common.xml file.

When I send message to JMS queues, only one queue is sending message requestChannel, rest of queues are not sending the message to destination [requestChannel].

Can Somebody suggest what I am doing wrong.

Can I use same varibale names in 2 diffenent files and call them in one main Conext file? [MainApplicationContext.xml], at present , I am doing this.

MainApplicationContext.xml file -- calls all other configuration files.

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

Common.xml -- have common channel details

<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 queue 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 queue 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>
1

1 Answers

4
votes

Bean IDs should be unique within the bean context. There are ways to create multiple contexts with parent/child relationships, which might be what you were expecting, but "import" does not do that. So the bean with id="jsmInputQueueAdapter_au" defined in config2.xml replaces the previous bean that had that id defined in config1.xml.

Also, in your example, both beans have the same attributes, including destination="InputQueueOne".

Update: As an example of creating parent-child hierarchies of bean contexts, see Spring contexts hierarchy