felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bokie <jms.cer...@gmail.com>
Subject OSGi - Reactive Paradigm
Date Fri, 21 Oct 2016 09:53:52 GMT
An opportunity has come up to include OSGi in a new project I'm involved in.
I'd like to hear some opinions, consideration to take into account and
perhaps some experiences with focus on how the reactive paradigm should fit
in a very dynamic OSGi ecosystem where services can come and go at any time.

With the code below as an example, my concerns are primarily with the
subscribe method where we are essentially passing it a listener,
'/doSomethingUseful/'; a no-no as per the *Whiteboard* pattern.
Another concern worth some thought is the /Subscription/ instance returned
from the same method which can become 'stale' at any time; the client can be
notified of this when /SomeService/ gets unbound but, how should
/SomeService/ handle the (multiple) subscription instances it could be
holding on to when it gets deactivated - cancel them? forcing the client
into a /subscription.isCancelled()/ logic.

I'm very interested to hear from you guys and thanks in advance...

class SomeServiceClient {

  @Reference
  private SomeService someService;

  private Subscription subscription;
  
  @Activate
  public void activate() {
    Parameters params = createParamStructure(config);
    // long living subscription?
    subscription = someService.subscribe(params, this::doSomethingUseful);
  }
  
  private void doSomethingUseful(MessageOfInterest msg) {
    // doing something interesting with msg
    // possibly called every second
  }
  
  @Deactivate
  public void deactivate() {
    subscription.cancel();
  }
}



--
View this message in context: http://apache-felix.18485.x6.nabble.com/OSGi-Reactive-Paradigm-tp5018956.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message