Search code examples
apache-karafkaraf

karaf: sharing data between bundles


How can I share data between bundles in Karaf? I am loading two bundles in different features. I want to write into something like a shared memory segment from one of the bundles and read it from another bundle. Thanks


Solution

  • Basically you can use all ways to communicate as in any other java application. Not all libraries are nicely compatible to OSGi though.

    One built in way to communicate in a loosely coupled way is the eventadmin service. See this tutorial from vogella for example.

    The most typical case in OSGi is to let one bundle offer an OSGi service and the other one call it.

    There are also libs like hazelcast which use kind of a shared memory even between nodes of a cluster. It is difficult to recommend one way without knowing more about your requirements and what you are trying to do.