Skip to content
Discussions/App Development/Read CommandCompletionStream response and stopForum ↗

Read CommandCompletionStream response and stop

App Development3 posts298 views6 likesLast activity Jun 2021
FR
FrankieOP
May 2021

I got two questions here.

  1. In what condition onComplete() will be called?
       Disposable t = res.subscribeWith(new DisposableSubscriber<CompletionStreamResponse>(){
            @Override
            public void onNext(CompletionStreamResponse completionStreamResponse) {
                completionStreamResponse.getCompletions()
                        .forEach(completion -> {
                           //do something here. 
                        });
            }
            @Override
            public void onError(Throwable throwable) {
                // do something here               
            }

            @Override
            public void onComplete() {                

            }
        });
  1. If a caller starts to stream the completions from an offset, the completion stream will be hanging there waiting after all the results been streamed out. Is there any way to find out it has reached the end of the ledger and stop it?
ST
stefanobaghino-da
May 2021

Regarding your first question, onComplete is called when a stream emits its last element. The completion stream however never ends, so you should never see that being called.

Regarding the second, it’s a bit tricky, because there is a CompletionEnd service but that returns the offset to which you are supposed to subscribe to, I don’t think you could use it to detect when you reached the ledger end.

The completion service is not designed to access historical data, but to keep up with an ongoing stream of commands. What is it exactly that you need? Unless you are explicitly looking for failures that happened in the past, you are more likely to get useful information using the transaction service, which can be queried for historical data by giving two explicit offsets.

FR
Frankie
Jun 2021

Thanks for the answer. I was just exploring those services and see what we can get from them. Also looking into the impact that pruning potential can bring into those services.

← Back to Discussions