Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1362

akka grpc server stream cannot return every result in real time #1735

$
0
0

First of all, I have a server stream method. In the method, I will request an actor in a loop. I expect that after each request is responded, the application will return the result to the caller. But no, I found that it still waits for all responses to be completed before returning, is this normal?

// The code is as follows, for the convenience of observing the results, I added sleep
override def itKeepsReplying(in: HelloRequest): Source[HelloReply, NotUsed] = {
    Source(1 to 10).map(index => {
        Thread.sleep(5000)
        HelloReply(index)
    })
}

In order to confirm whether grpc itself supports, I tried java’s implementation of this piece
If you want to send data to the caller:responseObserver.onNext(responseBuilder.build());
If you want to end this call: responseObserver.onCompleted();
Data is sent to the caller every time onNext is called

So my question is:
Is my assumption correct? Can akka-grpc do it
If it can be done, please give an example

7 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 1362

Trending Articles