Question

I have a Camel route using blueprint and Camel PropertiesComponent for configuration, I can run it standalone via 'mvn camel:run' or I can install it into a Karaf container. Both work great and discover the properties and inject them into the route.

What I cannot figure out is how to persist the properties when they change at runtime (as an example, I want to set a marker when the route stops/shutsdown and then read it back when the route starts).

I have read about OSGi ConfigAdmin - but this doesn't seem to support persisting properties. I have also read about the OSGi preferences service (which does support persistence) - but, how do I implement this so that I can run it standalone or in the container? which will require the Camel route to have a reference to the service thus depending on OSGi?

Is there a way to abstract the preferences service in such a way that standalone it does not depend on the container service?

thanks in advance.

Was it helpful?

Solution

The ConfigurationAdmin compendium service in OSGi does support persisting properties. In fact it does so by default (the data ends up in the bundle cache, so you need to make sure you're not wiping that on every restart, which is bad practice anyway).

If you use the one from Apache Felix, you even get an option to:

  1. Reconfigure the location where the data is persisted.
  2. Provide your own storage back-end, if you want to use a database or something.

See: http://felix.apache.org/documentation/subprojects/apache-felix-config-admin.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top