public class BackpressuredStreamFromAsyncSource<MessageType>
extends Object
The fundamental concept we are trying to follow in Nova's comm packages is that we want to offer backpressured
streams of messages. Such streams can easily be created from sync sources / sources that need to be polled
(e.g. kafka) using Flowable.generate().
For async sources, this is not so trivial, therefore we provide this helper class. It may look totally strange to
have an async, probably multi threaded sources and process this in a serialized, blocking, "pull style" manner,
but we consider the ability to apply backpressure from the consumers more important than throughput.
Using the backpressured stream means that - per default - incoming messages will only be read as fast as the slowest
consumer is able to handle them, therefore it is easy to slow down the performance of a whole server. We are aware of
that risk, but think that RxJava provides enough easy-to-use tools to cope with that situation.
And yes, it is super slow compared to PublishSubject (roughly 10% of the performance) or direct handler invocation
(roughly 1% of the performance), so it is not well suited for high frequency trading apps, but in "normal" cases,
we think that the performance is tolerable since request processing will anyway be orders of magnitude slower than the
pure dispatching.