Search code examples
osgiapache-karafapache-felix

OSGI: What happens when an already busy service is called?


Suppose I have a bundle that exposes a service that does some long work. The service is called when already running. What happens to the new invoke?

  • the new invoke gets ignored?
  • the new invoke gets put on hold?
  • the invoker gets an exception?

The osgi documentation https://docs.osgi.org/specification/ does not seem to contain the answer. Nor the documentation of Apache Felix and Apache Karaf.


Solution

  • Calling the service works exactly like a method call in java. So when you call a service while it is already running then it runs the code in one more thread.

    So as a developer you have to either make sure your code is thread safe or do locking as needed.