客戶端解決:
public class ManualFlowControlClient {
private static final Logger logger =
Logger.getLogger(ManualFlowControlClient.class.getName());
public static void main(String[] args) throws InterruptedException {
final CountDownLatch done = new CountDownLatch(1);
// Create a channel and a stub
ManagedChannel channel = ManagedChannelBuilder
.forAddress("localhost", 50051)
.usePlaintext()
.build();
StreamingGreeterGrpc.StreamingGreeterStub stub = StreamingGreeterGrpc.newStub(channel);
// When using manual flow-control and back-pressure on the client, the ClientResponseObserver handles both
// request and response streams.
ClientResponseObserver<HelloRequest, HelloReply> clientResponseObserver =
new ClientResponseObserver<HelloRequest, HelloReply>() {
ClientCallStreamObserver<HelloRequest> requestStream;
@Override
public void beforeStart(final Cl