ObservableHandler can miss events depending on ordering
Vertx 3.3.3
A good example of this is doing a get from the Hazelcast version of MultiMap (HazelcastAsyncMultiMap). Let's say we have something like this (subs is an AsyncMultiMap):
def observeGet = RxHelper.<AsyncResult<ChoosableIterable<ServerID>>>observableHandler()
return observeGet.map {
if (it.failed()) {
throw it.cause()
}
return new MapEntry(address, Lists.newArrayList(it.result()))
}.doOnSubscribe() {
subs.get(address, observeGet.toHandler())
}
When the observable returned here is subscribed to (this happens be from inside a flatMap call, but you could create and subscribe to it directly) we'll call get. If the get request is fulfilled from the cache (line 92 of HazelcastAsyncMultiMap) then we immediately call handle on ObservableHandler. Since we aren't yet fully subscribed (the subscribe call on the handler doesn't happen until after the doOnSubscribe callback. We end up discarding the event. Then when the subscribe call occurs, we simply call fireComplete and the event emission is lost.
There doesn't appear to be a way to guarantee that the called to handle won't happen before the call to subscribe in this case. I've even tried the experiemental doOnRequest and that's not late enough either. About the only choice is to put the call into some kind of deferred async request and even that's not 100% gauranteed to work. It would be better if in this case ObservableHandler kept track of the early event and emitted it at the point of subscription. I'm planning to add that code in our environment and I would be happy to provide it back if that helps.
that's a good idea to buffer such events, the ObservableFuture does that already but for a single event.
Interesting -- maybe I can switch to that in my code (this particular handler is single, not multi). Either way I'm still planning to create a custom version that adds this since I have other cases that are multi.
that's also something to take in account when we will look at RxJava2 support
Since you mention it ;), where is that support on your roadmap?
I think it should be added in the coming months, depending on demand.