Hi Camel Users, This is my first post and hopefully a challenging one for those interested. Firstly I am using Camel 2.10.0 with Apache Karaf 2.2.9, lets get that out of the way and having great fun. Now to the issue at hand: I want to build a mechanism to be able to dynamically add routes of a particular kind. More concretely I am using the camel-netty component as a listener which accepts a binary protocol, has a custom codec to convert to a POJO representation, pass that to a transformer and route the output of that to a queue, oneway traffic only - a fairly straightforward use case. Additionally I want to be able to create multiple instances of this type of route with different configurations e.g., each instance would typically differ by host/port of the consuming endpoint and perhaps the destination queue name.
My first attempt to do this led me to the ManagedServiceFactory mechanism of the OSGi config admin service. I reasoned that I could use this service to configure an extended CamelContext (or more accurately an OsgiDefaultCamelContext) which would create a new CamelContext instance each time a new config file with the appropriate factory PID prefix was dropped into Karaf's /etc folder. Here is my initial experiment with a simple file route to prove the concept: I include the camel-core-osgi dependency in my maven project as well as the osgi.core version 4.2.0. Here is my blueprint.xml with the ManagedServiceFactory details: Interestingly and quite conveniently blueprint makes certain aspects of the environment available c.f., blueprintBundleContext above, which is required for me to create the OsgiDefaultCamelContext (a normal DefaultCamelContext won't work as it won't have access to the Osgi container). All well and good so far. It seems to work except for one small quirk; lets say before installing the feature in karaf I have one or more configuration files in /etc as follows: MyFactory-1.cfg MyFactory-2.cfg then I seem to get 3 camel context instances created, 2 of which have the same service PID (odd) (remember the service PID is the factory PID plus a UUID tacked on). However if I start with no config files and install the feature then routes are added in the proper number as I add the config files. Has one seen this behaviour before and additionally can some of you more expert Camel users please comment on the approach above ? I will next attempt to implement the actual netty-based route and test it. BTW of course this same type of approach could be achieved also by dropping xml route configurations into the deploy folder, however the ManagedServiceFactory seems at first glance a more elegant way to achieve this. Many Thanks, Declan -- View this message in context: http://camel.465427.n5.nabble.com/Using-ManagedServiceFactory-to-dynamically-deploy-routes-tp5719969.html Sent from the Camel - Users mailing list archive at Nabble.com.