...

/

Server-Side Implementation of Server Streaming RPC

Server-Side Implementation of Server Streaming RPC

Implement the server side of a server-streaming readFile RPC in the FTP service.

In this lesson, we demonstrate the server-side implementation of server streaming readFile RPC. The client will send a file name to the server, and the server will respond by streaming the file to the client. The server-side logic is located in the ftp-service module. Open the FTPService class in the src/main/java/io/datajek/ftpservice/server package. This class implements the FTP service as defined in the proto file. We will add the readFile method in the FTPService class as follows:

@Override
public void readFile(MetaData request, StreamObserver<ReadFileResult> responseObserver) {
}
readFile method in FTPService class

readFile method

The method shown above takes two parameters: request of type MetaData and responseObserver of type StreamObserver<ReadFileResult>.

  1. The MetaData message is defined in the ftp-service.proto file and contains the name of the file to be read. ...