Closed pallavijaini closed 9 years ago
I can see why this happens: Spring Cloud Connectors uses SingletonBeanRegistry.registerSingleton()
to register beans for service instances and this is not idempotent (and never has been). It could be fixed by registering a proper bean definition which wraps the singleton instance, e.g. in a FactoryBean
.
The workaround seems fine though (don't import the same file twice). Also, if you didn't use XML, maybe the problem would go away?
Thanks for the inputs, i have registered the bean definition and it fixed the issue
I am importing a context file in one of my maven project and that context file is creating the cloud rabbit connection factory and one of the dependency component of the project also importing the same context file. When i was trying to deploy in pivotal cloud foundary(PCF), it is giving the below error
'Caused by: java.lang.IllegalStateException: Could not register object [org.springframework.cloud.service.messaging.RabbitConnectionFactoryFactory@2e16584] under bean name 'commonBtmAmqpConnectionFactory': there is already object [org.springframework.cloud.service.messaging.RabbitConnectionFactoryFactory@1bcfbe96] bound'
Bean which is creating the connection factory.
<beans profile="cloud"> <cloud:rabbit-connection-factory id="commonBtmAmqpConnectionFactory" service-name="actmon-rabbitmq-service"/> </beans>
After removing the import of context file from one of the component (I removed the context file from the main project and did not make any changes to the dependency component), i was able to deploy the component in PCF. Here my question is Standard Spring container can handle import of the same context file and multiple times. Spring Cloud Connector is behaving different, am i missing something here?.