Hi ! I'm trying to create a WAR application that create routes between multiple sources and one destination. The sources can be SQL Database, MongoDB, REST Service, etc and parameters of these connections are stored in a external database.
Until now, I was using Spring to initialize the SQLComponent or MongoClient bean but it wasn't dynamic : <bean id="sqlConnector" class="ConnectorSQL"> <constructor-arg name="identifiant" value="1" /> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" factory-bean="sqlConnector" factory-method="setupDataSource"> </bean> <bean id="sql" class="org.apache.camel.component.sql.SqlComponent"> <property name="dataSource" ref="dataSource" /> </bean> I need to do it in the Java code. Moreover, I have a list of datasources and I have to create as many SQLComponent as my number of SQL datasources (the same for MongoDB). *The problem is, I don't have any idea where I can create them..* I've created an interface ConnectorEndpoint which regroups the parameters needed by each type of Camel Component. The process looks like that : DAO -> getDatasources() -> create the ConnectorEndPoint -> constructor args of the RouteBuilder -> create the route And my code looks like that : *In my RouteBuilder constructor : * for (Datasource datasource : listDatasources){ switch (datasource.getType()) { case "oracle" : srcs.add(new ConnectorSQL(datasource)); // I was thinking about create them here but I have to give them dynamic name // to match with the name of the component *to("sql" + id + "://" + query)* in the route, no ? break; case "elastic" : srcs.add(new ConnectorElasticSearch(datasource)); break; case "mongo" : srcs.add(new ConnectorMongoDB(datasource)); // I was thinking about create them here break; case "rest" : srcs.add(new ConnectorREST(datasource)); break; } } *The configure method :* public void configure() { for (ConnectorEndPoint src : this.srcs) { if (src instanceof ConnectorSQL){ from("direct:" + src.getId()).*to("sql" + id + "://" + query)* .to(dest.getRouteTo()); } else if (src instanceof ConnectorMongoDB){ from("direct:" + src.getId()).to(mongodb:mongoDriver?database=...) .to(dest.getRouteTo()); } else if (src instanceof ConnectorREST){ ... } } In fact, I don't understand where the SQLComponents must be in the application for the Camel Context can be able to find them. I have thought about a Registry but how can I give it to the Camel Context and where do I have to create it ? I know that's a long message but I'll thank everyone that would try to help me ;) -- View this message in context: http://camel.465427.n5.nabble.com/Create-multiple-SQLComponent-tp5773059.html Sent from the Camel - Users mailing list archive at Nabble.com.