armybuilder/src/main/java/net/mekstrike/armybuilder/ArmyBuilderService.java
/**
   * Server mode: this is the Dapr method to receive Invoke operations via Grpc.
   *
   * @param request          Dapr envelope request,
   * @param responseObserver Dapr envelope response.
   */
Server mode: this is the Dapr method to receive Invoke operations via Grpc.
@param request          Dapr envelope request,
@param responseObserver Dapr envelope response.
Server mode : this is the Dapr method to receive Invoke operations via Grpc . @param request Dapr envelope request @param responseObserver Dapr envelope response .
@Override
  public void onInvoke(CommonProtos.InvokeRequest request,
      StreamObserver<CommonProtos.InvokeResponse> responseObserver) {
    try {
      if ("createArmy".equals(request.getMethod())) {
        ArmyRequest armyRequest = ArmyRequest.newBuilder().mergeFrom(request.getData().getValue()).build();
        var army = createArmy(armyRequest);
        CommonProtos.InvokeResponse.Builder responseBuilder = CommonProtos.InvokeResponse.newBuilder();
        responseBuilder.setData(Any.pack(army));
        responseObserver.onNext(responseBuilder.build());
      }
    } catch (InvalidProtocolBufferException e) {
      System.out.println("Error merging messages!");
      e.printStackTrace();
    } finally {
      responseObserver.onCompleted();
    }
  }
@ Override public void onInvoke ( CommonProtos . InvokeRequest request , StreamObserver < CommonProtos . InvokeResponse > responseObserver ) { try { if ( "createArmy" . equals ( request . getMethod ( ) ) ) { ArmyRequest armyRequest = ArmyRequest . newBuilder ( ) . mergeFrom ( request . getData ( ) . getValue ( ) ) . build ( ) ; var army = createArmy ( armyRequest ) ; CommonProtos . InvokeResponse . Builder responseBuilder = CommonProtos . InvokeResponse . newBuilder ( ) ; responseBuilder . setData ( Any . pack ( army ) ) ; responseObserver . onNext ( responseBuilder . build ( ) ) ; } } catch ( InvalidProtocolBufferException e ) { System . out . println ( "Error merging messages!" ) ; e . printStackTrace ( ) ; } finally { responseObserver . onCompleted ( ) ; } }
Server mode: this is the Dapr method to receive Invoke operations via Grpc.
Server mode : this is the Dapr method to receive Invoke operations via Grpc .
// Create an the dapr envelope response