RxJava-file and operator chaining

老子叫甜甜 提交于 2020-05-27 06:19:09

问题


I'm trying to reactively tail a log file using RxJava-File:

    File file = new File(".\\server.log");
    Observable<String> newLines =
            FileObservable.tailer()
                    .file(file)
                    .startPosition(file.length())
                    .sampleTimeMs(1000)
                    .chunkSize(8192)
                    .utf8()
                    .tailText();

    newLines.subscribe(System.out::println);

and it works as expected. But as soon as I try to chain some more operators, I get problems. For instance, changing to

  newLines.filter(LogfileWatcher::error).subscribe(System.out::println);

(where error() is a simple function String -> Boolean) I get output only after the first append to the file, but not the subsequent ones. Similar problems appear when using window() or several other operators.

What am I doing wrong?


回答1:


Backpressure support had to be fixed in rxjava-file and your test case is reported to be working as of rxjava-file 0.3.3 on Maven Central.



来源:https://stackoverflow.com/questions/32646260/rxjava-file-and-operator-chaining

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!