ReplaySubject问题

时间:2018-07-04 18:15:55

标签: rx-java

不确定我是否以正确的方式使用此功能。我有许多线程正在将项目添加到ReplaySubject中。我想批量写入数据库。在主线程上,我有这样的代码:

while ((x < y) ) {  //Still some items to process
    if (errorOccured == true) {
        replaySubject.onCompleted();
    }   

    //Process 100 messages at a time
    replaySubject.buffer(100).subscribe(list -> dbHandle.setBatch(list));   
} 

但是,RxJava本身由于以下跟踪而崩溃:

*at rx.subjects.ReplaySubject$ReplayUnboundedBuffer.drain(ReplaySubject.java:642)
at rx.subjects.ReplaySubject$ReplayProducer.request(ReplaySubject.java:1268)
at rx.Subscriber.setProducer(Subscriber.java:211)
at rx.subjects.ReplaySubject$ReplayState.call(ReplaySubject.java:384)
at rx.subjects.ReplaySubject$ReplayState.call(ReplaySubject.java:360)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.Observable.subscribe(Observable.java:10352)
at rx.Observable.subscribe(Observable.java:10319)
at rx.Observable.subscribe(Observable.java:10159)
at com.model.JobStateAndStatsManager.areTheThreadsDone(JobStateAndStatsManager.java:54)

0 个答案:

没有答案