Class GrpcInboundGateway

All Implemented Interfaces:
io.grpc.BindableService, Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, Lifecycle, Phased, SmartLifecycle, ComponentSourceAware, ExpressionCapable, IntegrationPattern, NamedComponent, IntegrationInboundManagement, IntegrationManagement, ManageableLifecycle, ManageableSmartLifecycle, TrackableComponent

public class GrpcInboundGateway extends MessagingGatewaySupport implements io.grpc.BindableService
The MessagingGatewaySupport implementation for gRPC BindableService. An instance of this class requires a BindableService class from the gRPC service definition. Only standard 'grpc' services are supported which implements a generated AsyncService interface. This gateway is a BindableService by itself to be registered with the gRPC server. An internal proxy is created to intercept gRPC method calls and convert them to Spring Integration messages. A reply from the downstream flow is produced back to the gRPC response payload. The request payload is a Proto message from gRPC request. The reply payload must be a Proto message for gRPC response.

This gateway supports all the gRPC MethodDescriptor.MethodType types. All the requests are produced to downstream flow in a reactive manner via MessagingGatewaySupport.sendAndReceiveMessageReactive(Object). The MethodDescriptor.MethodType.UNARY and MethodDescriptor.MethodType.BIDI_STREAMING are same from the downstream handling logic perspective. The MethodDescriptor.MethodType.CLIENT_STREAMING produces a Flux of gRPC request payloads. The MethodDescriptor.MethodType.SERVER_STREAMING reply can be a single entity or a Flux of them.

For convenience, the GrpcHeaders are populated into a request message. Such information can be used, for example, in downstream flow for routing.

Since:
7.1
Author:
Artem Bilan
  • Constructor Details

    • GrpcInboundGateway

      public GrpcInboundGateway(Class<? extends io.grpc.BindableService> grpcServiceClass)
  • Method Details

    • onInit

      protected void onInit()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this for initialization logic.
      Overrides:
      onInit in class MessagingGatewaySupport
    • bindService

      public io.grpc.ServerServiceDefinition bindService()
      Specified by:
      bindService in interface io.grpc.BindableService