Project: talendesb
Issue TESB-4116: Multiple Redundant Connection Factories and Components Registered in Camel Context
Code generated by ESB studio seem to generate multiple redundant component registrations and also redundant connections factories. For example, suppose multiple activemq endpoints are referenced in route. They all refer to the same activemq connection, but they refer to different destination topics and routes. In 5.0M4 this was the code that was generated. I have to confirm that this is still the case in RC3. Note that each component is registered with the camelContext, i.e. cActiveMQ1 is a Camel component that is used exactly once. Likewise, a separate connection factory is created each time.	camelContext.addComponent("cActiveMQ1",	org.apache.activemq.camel.component.ActiveMQComponent	.jmsComponent(amqConnectionFactory));	amqConnectionFactory = new org.apache.activemq.ActiveMQConnectionFactory(	"tcp://localhost:61616");	camelContext.addComponent("cActiveMQ7",	org.apache.activemq.camel.component.ActiveMQComponent	.jmsComponent(amqConnectionFactory));	amqConnectionFactory = new org.apache.activemq.ActiveMQConnectionFactory(	"tcp://localhost:61616");	camelContext.addComponent("cActiveMQ2",	org.apache.activemq.camel.component.ActiveMQComponent	.jmsComponent(amqConnectionFactory));	amqConnectionFactory = new org.apache.activemq.ActiveMQConnectionFactory(	"tcp://localhost:61616");	camelContext.addComponent("cActiveMQ4",	org.apache.activemq.camel.component.ActiveMQComponent	.jmsComponent(amqConnectionFactory));	amqConnectionFactory = new org.apache.activemq.ActiveMQConnectionFactory(	"tcp://localhost:61616");	camelContext.addComponent("cActiveMQ6",	org.apache.activemq.camel.component.ActiveMQComponent	.jmsComponent(amqConnectionFactory));	amqConnectionFactory = new org.apache.activemq.ActiveMQConnectionFactory(	"tcp://localhost:61616");	camelContext.addComponent("cActiveMQ9",	org.apache.activemq.camel.component.ActiveMQComponent	.jmsComponent(amqConnectionFactory)); One approach is to manage context scope resources such as components via tabs within the cConfig component. Things like the activemq connection and the formal camel activemq component (i.e. endpoint factory) should be named properties that can then be referenced by actual activemq endpoint instances in much the same way sqlEndpoints reference a shared db connection. But these _should_not_ be global variables accessed via the Studio context. They should be attached to the camel context.
Story points: 1