-
1. Re: Deploying features using <config> to set different property values for each
ffang Oct 28, 2012 8:58 PM (in response to plord_plord)Hi,
I don't think you can have multiple instance of exact same bundle in one OSGi container, so there's only one mvn:com.foo.poc.fuse/fuse-dyna-route/1.0.0-SNAPSHOT get installed and only one property could get picked up.
Freeman
-
2. Re: Deploying features using <config> to set different property values for each
plord_plord Oct 29, 2012 12:38 PM (in response to ffang)But you can do this using the Profile mechanism from fabric. I was under the assumption that you could therefore use the feature mechanism without fabric to do the same thing.
-
3. Re: Deploying features using <config> to set different property values for each
jrawlings1980 Oct 29, 2012 4:44 PM (in response to plord_plord)I don't think you can do this using a single Fabric profile. You would need to create two profiles with different config admin properties for your configurable endpoints and assign to different containers.
The way we have done this is by using d-osgi and the ESB registry.
We have multiple instances of the same version bundle but in different lightweight containers. These bundles expose a service using the same interface with a service property to identify each implementation. This property is set using Fabric profiles.
The calling service looks up the required bundle from the registry using d-osgi and a service filter which corresponds to the service property.
This provides loosely coupled services which can be dynamically added and registered within each OSGi registry and in turn the Zookeeper registry. This also provides a good scalable option as the calling service can randomly use one of a list of services returned by Zookeeper.
I have added some code snippets to hopefully add clarity:
Service Implementation bundle uses Config admin service to set a service property and the different endpoint.
<cm:property-placeholder persistent-id="com.company "> <cm:default-properties> <cm:property name="identifier.key" value="0"></cm:property> <cm:property name="endpoint" value="activemq:somewhere"></cm:property> </cm:default-properties> </cm:property-placeholder> <service ref="myService" auto-export="interfaces"> <service-properties> <entry key="service.exported.interfaces" value="*"></entry> <entry key="identifier.key" value="${identifier.key}"></entry> </service-properties> </service> <endpoint uri="{{endpoint}}" id="myEndpoint"></endpoint> <route id="myRoute"> <from uri="somewhere"></from> <to ref="myEndpoint"></to> </route>
Calling service in Java DSL so we can dynamically lookup multiple instances matching the same filter and load balance between them. Not sure if this is possible in XML DSL.
String indentifyingKey = request.getIdentifyingKey(); String filter = "(identifier.key=" + indentifyingKey + ")"; BundleContext bundleContext = FrameworkUtil.getBundle(MyServiceCaller.class).getBundleContext(); Collection<ServiceReference<MyService>> serviceReferences = bundleContext.getServiceReferences(MyService.class, filter); LOGGER.debug("Found ["+ serviceReferences.size() +"] my service(s) for: " + indentifyingKey); ServiceReference<MyService> serviceReference = (ServiceReference<MyService>) getRandomService(serviceReferences.toArray()); MyService myService = bundleContext.getService(serviceReference);
Example fabric profiles...
fabric:profile-create --parents mq-base --parents default --parents dosgi --parents camel my-profile fabric:profile-edit -r mvn:org.fusesource.esb/fuse-esb/7.0.2.fuse-097/xml/features my-profile fabric:profile-edit -r mvn:com.company/my-features/1.0-SNAPSHOT/xml/features my-profile fabric:profile-edit --features jms-sr-comp1 my-profile fabric:profile-edit --pid com.company/identifier.key=1 my-profile fabric:profile-edit --pid com.company/endpoint=jms-sr-comp1 my-profile fabric:container-create --parent root --profile my-profile my-server-1 fabric:profile-create --parents mq-base --parents default --parents dosgi --parents camel my-profile fabric:profile-edit -r mvn:org.fusesource.esb/fuse-esb/7.0.2.fuse-097/xml/features my-profile fabric:profile-edit -r mvn:com.company/my-features/1.0-SNAPSHOT/xml/features my-profile fabric:profile-edit --features jms-sr-comp1 my-profile fabric:profile-edit --pid com.company/identifier.key=2 my-profile fabric:profile-edit --pid com.company/endpoint=jms-sr-comp2 my-profile fabric:container-create --parent root --profile my-profile my-server-2
I would appreciate peoples thoughts on this.
Thanks, James.
-
4. Re: Deploying features using <config> to set different property values for each
ffang Oct 29, 2012 8:48 PM (in response to jrawlings1980)Hi,
Yeah, leverage fabric to deploy it on different container is the way to go, that said, same bundle with different configuration is possible on different containers.
Freeman
-
5. Re: Deploying features using <config> to set different property values for each
plord_plord Oct 30, 2012 12:58 PM (in response to ffang)After much testing I have come to the conclusion that the profile mechanism to deploy the same bundle to the same container with a different config is not possible. In order to do this, the bundle name needs to be changed.
Of course deploying the same bundle to different containers is always possible.