0

I've a Java application in which I need to be able to connect to multiple(3) systems for reading messages from a queue. I'm using Spring framework in applicationContext file.

I'm getting following runtimeError:

"Parameter 1 of method jmsListenerContainerFactory in ... required a single bean, but 3 were found"

I tried using scope="prototype" at CachedContainerFactory bean level in the applicationContext file, but no luck.

Not sure how to fix this.

Thanks.

1 Answers1

0

I wasn't able to reproduce your error, but I am able to use multiple connection factories without issues. Specifically, I use CachingConnectionFactory - I'm not aware of any CachedContainerFactory as you noted. Here's an example XML configuration for 2 VPNs:

<bean autowire="default" class="org.springframework.jndi.JndiTemplate" id="v1Template" lazy-init="default">
    <property name="environment">
        <map>
            <entry key="java.naming.provider.url" value="smf://192.168.65.3:55555"/>
            <entry key="java.naming.factory.initial" value="com.solacesystems.jndi.SolJNDIInitialContextFactory"/>
            <entry key="java.naming.security.principal" value="default@v1"/>
        </map>
    </property>
</bean>

<bean autowire="default" class="org.springframework.jndi.JndiTemplate" id="v2Template" lazy-init="default">
    <property name="environment">
        <map>
            <entry key="java.naming.provider.url" value="smf://192.168.65.3:55555"/>
            <entry key="java.naming.factory.initial" value="com.solacesystems.jndi.SolJNDIInitialContextFactory"/>
            <entry key="java.naming.security.principal" value="default@v2"/>
        </map>
    </property>
</bean>

<bean autowire="default" class="org.springframework.jndi.JndiObjectFactoryBean" id="v1cf" lazy-init="default">
    <property name="jndiTemplate" ref="v1Template"/>
    <property name="jndiName" value="cf"/>
</bean>

<bean autowire="default" class="org.springframework.jndi.JndiObjectFactoryBean" id="v2cf" lazy-init="default">
    <property name="jndiTemplate" ref="v2Template"/>
    <property name="jndiName" value="cf"/>
</bean>

<bean class="org.springframework.jms.connection.CachingConnectionFactory" id="v1ccf">
    <property name="targetConnectionFactory" ref="v1cf"/>
    <property name="sessionCacheSize" value="10"/>
</bean>

<bean class="org.springframework.jms.connection.CachingConnectionFactory" id="v2ccf">
    <property name="targetConnectionFactory" ref="v2cf"/>
    <property name="sessionCacheSize" value="10"/>
</bean>

For additional configuration properties (if connecting to Solace using Spring XML configuration), please refer to the integration guide.

A similar issue was noted in another post - NoUniqueBeanDefinitionException in Spring annotation driven configuration.

dbsol
  • 36
  • 3