@@ -34,17 +34,15 @@ public class HelloWorldServer {
34
34
private void start () throws IOException {
35
35
/* The port on which the server should run */
36
36
int port = 50051 ;
37
- server = ServerBuilder .forPort (port )
38
- .addService (new GreeterImpl ())
39
- .build ()
40
- .start ();
37
+ server = ServerBuilder .forPort (port ).addService (new GreeterImpl ()).build ().start ();
41
38
logger .info ("Server started, listening on " + port );
42
39
Runtime .getRuntime ().addShutdownHook (new Thread () {
43
40
@ Override
44
41
public void run () {
45
- // Use stderr here since the logger may have been reset by its JVM shutdown hook.
42
+ // Use stderr here since the logger may have been reset by its JVM shutdown
43
+ // hook.
46
44
System .err .println ("*** shutting down gRPC server since JVM is shutting down" );
47
- HelloWorldServer .this .stop ();
45
+ // HelloWorldServer.this.stop();
48
46
System .err .println ("*** server shut down" );
49
47
}
50
48
});
@@ -61,7 +59,8 @@ private void stop() {
61
59
}
62
60
63
61
/**
64
- * Await termination on the main thread since the grpc library uses daemon threads.
62
+ * Await termination on the main thread since the grpc library uses daemon
63
+ * threads.
65
64
*/
66
65
private void blockUntilShutdown () throws InterruptedException {
67
66
if (server != null ) {
@@ -82,6 +81,13 @@ static class GreeterImpl extends GreeterGrpc.GreeterImplBase {
82
81
83
82
@ Override
84
83
public void sayHello (HelloRequest req , StreamObserver <HelloReply > responseObserver ) {
84
+ logger .info ("!!! Received call" );
85
+ try {
86
+ Thread .sleep (15000 );
87
+ } catch (InterruptedException e ) {
88
+ // TODO Auto-generated catch block
89
+ e .printStackTrace ();
90
+ }
85
91
HelloReply reply = HelloReply .newBuilder ().setMessage ("Hello " + req .getName ()).build ();
86
92
responseObserver .onNext (reply );
87
93
responseObserver .onCompleted ();
0 commit comments