Richard Searle


Stream I/O in RxJava

08 Feb 2014

The Netflix RxJava implementation explicitly drops the .Net Reactive Extensions operations that are used for (async) I/O. The available documentation is essentially silent on how one might implement simple I/O operations, such as reading from stdin.

A web search indicates that such operations are generally implemented using recursive schedulers, a topic which also has limited documentation.

This code snippet illustrates how this might be implemented.

Obviously this code consumes a thread to handle the blocking I/O, which is provided by a self contained scheduler to avoid the performance defect.

Camel RX integrates its existing Components with rxjava, allowing a very simple implementation Without the scanStream=true option the output is delayed by one line.