クラス GrpcOutboundGateway

実装済みのインターフェース一覧:
org.reactivestreams.Subscriber<Message<?>>AwareBeanClassLoaderAwareBeanFactoryAwareBeanNameAwareDisposableBeanInitializingBeanApplicationContextAwareOrderedComponentSourceAwareExpressionCapableOrderableMessageProducerHeaderPropagationAwareIntegrationPatternNamedComponentIntegrationManagementTrackableComponentMessageHandlerreactor.core.CoreSubscriber<Message<?>>

public class GrpcOutboundGateway extends AbstractReplyProducingMessageHandler
gRPC クライアント呼び出し用の送信ゲートウェイ。

このコンポーネントは gRPC スタブとして機能し、リクエストは入力メッセージに基づいて行われ、呼び出すターゲット gRPC サービスメソッドは、入力メッセージに対する SpEL 式に基づいて実行時に解決されます。

サポートされている gRPC リクエスト:

  • 単項 : 単一のリクエストオブジェクトを受け入れます
  • サーバーストリーミング : 単一のリクエストオブジェクトを受け入れます
  • クライアントストリーミング FluxMonoStreamSECollectionSE、単一のオブジェクトを受け入れます。
  • 双方向ストリーミング FluxMonoStreamSECollectionSE、単一のオブジェクトを受け入れます。
リクエストオブジェクトは、それぞれのサービス Protobuf から生成された、想定されるドメインエンティティである必要があります。

ゲートウェイからのリクエストの戻り値の型:

  • 単項 : デフォルトでは、レスポンスオブジェクトを含む Mono を返します。AbstractMessageProducingHandler.isAsync() が false に設定されている場合、レスポンスオブジェクト自体を返します。
  • サーバーストリーミング : レスポンスメッセージの Flux を返します
  • クライアントストリーミング : 単一のレスポンスを含む Mono を返します
  • 双方向ストリーミング : レスポンスメッセージの Flux を返します

導入:
7.1
作成者:
Glenn Renfro, Artem Bilan
  • コンストラクターの詳細

    • GrpcOutboundGateway

      public GrpcOutboundGateway(io.grpc.Channel channel, ClassSE<?> grpcServiceClass)
      Create a new GrpcOutboundGateway based on the gRPC service class and Channel for communication. The gateway is set to async mode by default.
      パラメーター:
      channel - 通信に使用する gRPC チャネル
      grpcServiceClass - gRPC サービスクラス (例: SimpleGrpc.class)
  • 方法の詳細

    • setMethodNameExpression

      public void setMethodNameExpression(Expression methodNameExpression)
      Set the Expression to resolve the gRPC method name at runtime. If not provided, the default expression checks the MessageHeaders for a GrpcHeaders.SERVICE_METHOD . If the expression is not set and the service has only one method, then the gateway will set the expression to use the name of that method.
      パラメーター:
      methodNameExpression - メソッド名を解決する式
    • setMethodName

      public void setMethodName(StringSE methodName)
      呼び出す gRPC メソッドの名前を設定します。メソッド名が指定されていない場合、デフォルトの式は MessageHeaders から GrpcHeaders.SERVICE_METHOD を探すか、単一のサービスメソッドの場合はそのメソッド名を使用します。
      パラメーター:
      methodName - 呼び出す gRPC メソッドの名前
    • setCallOptions

      public void setCallOptions(io.grpc.CallOptions callOptions)
      Set the CallOptions the RPC call. Default is CallOptions.DEFAULT
      パラメーター:
      callOptions - the CallOptions for the gateway.
    • doInit

      protected void doInit()
      オーバーライド:
      クラス AbstractReplyProducingMessageHandlerdoInit 
    • handleRequestMessage

      protected ObjectSE handleRequestMessage(Message<?> requestMessage)
      クラスからコピーされた説明: AbstractReplyProducingMessageHandler
      サブクラスはこのメソッドを実装して、リクエストメッセージを処理する必要があります。戻り値は、メッセージ、MessageBuilder、任意のプレーンオブジェクトです。基本クラスは、これらの開始点のいずれかからの返信メッセージの最終的な作成を処理します。戻り値が null の場合、メッセージフローはここで終了します。
      次で指定:
      クラス AbstractReplyProducingMessageHandlerhandleRequestMessage 
      パラメーター:
      requestMessage - リクエストメッセージ。
      戻り値:
      メッセージを処理した結果、または null