Issues with blocking observable
See original GitHub issueHi,
Having issues getting the blocking requests working. In order to support backwards compatibility in our clients we support returning both Observable<T> and T. To get the Observable we do:
Observable<ByteBuf> observable = template.requestBuilder().build().observe();
Observable<T> response = observable.map(new Func1<ByteBuf, T>() {
@Override
public T call(ByteBuf byteBuf) {
byteBuf.retain();
try {
InputStream stream = new ByteBufInputStream(byteBuf);
return streamToObject(stream, tClass);
} finally {
byteBuf.release();
}
}});
T item = response.toBlocking().last();
That works well for MOST of the times. However, sometimes we get:
java.util.NoSuchElementException: Sequence contains no elements
.
Anyone have any idea?
Issue Analytics
- State:
- Created 9 years ago
- Comments:19
Top Results From Across the Web
Using RX JAVA Blocking Observable effectively - Medium
In this article I am going to explain about Blocking Observables. As the name suggests, Blocking Observable is an Observable, which implements ...
Read more >java - Am I misusing rxJava by converting an observable into a ...
I use hystrix-feign to make the HTTP calls. BlockingObservable is a variety of Observable that provides blocking operators.
Read more >Intro - ReactiveX
Callbacks solve the problem of premature blocking on Future.get() by not allowing anything to block. They are naturally efficient because they execute when...
Read more >4. Applying Reactive Programming to Existing Applications
However, BlockingObservable is much more convenient in blocking environments that ... but in rare cases you must add concurrency to an existing Observable...
Read more >3 Common Rxjs Pitfalls (and how to avoid them)
We are going to go over why the issue happens and how to fix it. ... An observable itself is just a definition...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@NiteshKant at least I am not seeing that specific error any more. I also tried doing the same for futures with something like this;
observable.lastOrDefault().toBlocking().toFuture();
Does that sound right?
At what point will the default value be invoked? How can we be sure that the only case this happens if a response has been indeed been returned but the bytebuf was empty? Having huge issues trying to make this backwards compatible. Seems like we’re getting false defaults…
RC10 seems to be on rx-netty-0.3.17. Will 18 be rolled in to that? We also seem to be encountering this issue and am interested in a work around. Haven’t found anything yet, outside of retry, which isn’t great for all situations.