Source:
public static void startServer() throws Exception { server = ServerBuilder.forPort(18024) .addService(new PlatformServiceGrpc.PlatformServiceImplBase() { @Override public void getPlatformServer(ClientIdentification request, StreamObserver<PlatformInfo> responseObserver) { responseObserver.onNext(PlatformInfo.newBuilder().setSameConnection(true) .build()); responseObserver.onCompleted(); } @Override public StreamObserver<PlatformInboundInstruction> openStream( StreamObserver<PlatformOutboundInstruction> responseObserver) { return new StreamObserver<PlatformInboundInstruction>() { @Override public void onNext(PlatformInboundInstruction platformInboundInstruction) { } @Override public void onError(Throwable throwable) { } @Override public void onCompleted() { } }; } }) .addService(new EventSchedulerGrpc.EventSchedulerImplBase() { @Override public void scheduleEvent(ScheduleEventRequest request, StreamObserver<ScheduleToken> responseObserver) { String id = UUID.randomUUID().toString(); scheduled.put(id, request.getEvent()); responseObserver.onNext(ScheduleToken.newBuilder().setToken(id).build()); responseObserver.onCompleted(); } @Override public void rescheduleEvent(RescheduleEventRequest request, StreamObserver<ScheduleToken> responseObserver) { String token = request.getToken(); if (request.getToken().equals("")) { token = UUID.randomUUID().toString(); } scheduled.put(token, request.getEvent()); responseObserver.onNext(ScheduleToken.newBuilder() .setToken(token) .build()); responseObserver.onCompleted(); } @Override public void cancelScheduledEvent(CancelScheduledEventRequest request, StreamObserver<InstructionAck> responseObserver) { if (!scheduled.containsKey(request.getToken())) { responseObserver.onNext(InstructionAck.newBuilder() .setSuccess(false) .setError(ErrorMessage.newBuilder() .setMessage( "Schedule not found") .addDetails( "Detail1") .addDetails( "Detail2") .setErrorCode( "AXONIQ-2610") .build()) .build()); } else { scheduled.remove(request.getToken()); responseObserver.onNext(InstructionAck.newBuilder().setSuccess(true).build()); } responseObserver.onCompleted(); } }).build(); server.start(); }

Target:
static void startServer() throws Exception { server = ServerBuilder.forPort(18024) .addService(new PlatformServiceGrpc.PlatformServiceImplBase() { @Override public void getPlatformServer(ClientIdentification request, StreamObserver<PlatformInfo> responseObserver) { responseObserver.onNext(PlatformInfo.newBuilder().setSameConnection(true) .build()); responseObserver.onCompleted(); } @Override public StreamObserver<PlatformInboundInstruction> openStream( StreamObserver<PlatformOutboundInstruction> responseObserver) { return new StreamObserver<PlatformInboundInstruction>() { @Override public void onNext(PlatformInboundInstruction platformInboundInstruction) { } @Override public void onError(Throwable throwable) { } @Override public void onCompleted() { } }; } }) .addService(new EventSchedulerGrpc.EventSchedulerImplBase() { @Override public void scheduleEvent(ScheduleEventRequest request, StreamObserver<ScheduleToken> responseObserver) { String id = UUID.randomUUID().toString(); scheduled.put(id, request.getEvent()); responseObserver.onNext(ScheduleToken.newBuilder().setToken(id).build()); responseObserver.onCompleted(); } @Override public void rescheduleEvent(RescheduleEventRequest request, StreamObserver<ScheduleToken> responseObserver) { String token = request.getToken(); if (request.getToken().equals("")) { token = UUID.randomUUID().toString(); } scheduled.put(token, request.getEvent()); responseObserver.onNext(ScheduleToken.newBuilder() .setToken(token) .build()); responseObserver.onCompleted(); } @Override public void cancelScheduledEvent(CancelScheduledEventRequest request, StreamObserver<InstructionAck> responseObserver) { if (!scheduled.containsKey(request.getToken())) { responseObserver.onNext(InstructionAck.newBuilder() .setSuccess(false) .setError(ErrorMessage.newBuilder() .setMessage( "Schedule not found") .addDetails( "Detail1") .addDetails( "Detail2") .setErrorCode( "AXONIQ-2610") .build()) .build()); } else { scheduled.remove(request.getToken()); responseObserver.onNext(InstructionAck.newBuilder().setSuccess(true).build()); } responseObserver.onCompleted(); } }).build(); server.start(); }