Server-Side Implementation of Server Streaming RPC
Explore how to implement server-side logic for server streaming RPC in gRPC. Learn to stream files from server to client in chunks, manage file paths, handle exceptions, and use StreamObserver for efficient communication.
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:
@Overridepublic void readFile(MetaData request, StreamObserver<ReadFileResult> responseObserver) {}
readFile method
The method shown above takes two parameters: request of type MetaData and responseObserver of type ...