These are chat archives for ReactiveX/RxJava

27th
Nov 2016
Ronen
@ronenhamias
Nov 27 2016 03:55
Hello Rx java i am using Rx Java for the open source project http://scalecube.io/ and got the following exception Caused by: rx.exceptions.MissingBackpressureException: PublishSubject: could not emit value due to lack of requests. what would be the best Backpressure strategy to use when i cant afford loosing messages and dont want to buffer to many messages ? can someone better explain this exception? Thanks in advance !
David Karnok
@akarnokd
Nov 27 2016 08:20
@ronenhamias What is your data source? For what chain do you get the error? You could switch to a built-in source that does honor backpressure. Otherwise, you have to buffer or drop values.
Ronen
@ronenhamias
Nov 27 2016 08:22

i am accepting messages on netty listener ```@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
Message message = (Message) msg;
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Received: {}", message);
}

incomingMessagesSubject.onNext(message);

}```

```
and consumers subscribe on the subject
 @Nonnull
  @Override
  public final Observable<Message> listen() {
    checkState(!stopped, "Transport is stopped");
    return incomingMessagesSubject.onBackpressureBuffer(DEFAULT_BUFFER_LIMIT).asObservable();
  }
currently using onBackpressureBuffer
David Karnok
@akarnokd
Nov 27 2016 08:25
I see. I don't know enough about Netty but RxNetty does seem to work without backpressure problems. Otherwise, you have to tie the reading of a channel to the request amount of the downstream by building a custom operator and not using PublishSubject.
Ronen
@ronenhamias
Nov 27 2016 08:32
i will look deeper into RxNetty
Stanislav Shakirov
@punksta
Nov 27 2016 10:27

Hello! I need to make request after complete of changing ui.
pseudo-code

someUiEvents()
.debounce()
.filter { it is EditComplete }
.flatMap { doRequest }
.doOnNext { updateUi }

Can I cancel(unsubscribe) from doRequest if got new event?

I can create subscription inside flatMap and cancel it every time I got emitting. But can it be solved ussing operators only?
Dorus
@Dorus
Nov 27 2016 12:04
@punksta yeah you can use switch for that.