Class GrpcInboundGateway
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.MessagingGatewaySupport
org.springframework.integration.grpc.inbound.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
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
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
MessagingGatewaySupport.ConvertingMessagingTemplateNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
Fields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
messagingTemplateFields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionGrpcInboundGateway(Class<? extends io.grpc.BindableService> grpcServiceClass) -
Method Summary
Modifier and TypeMethodDescriptionio.grpc.ServerServiceDefinitionprotected voidonInit()Subclasses may implement this for initialization logic.Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
buildErrorMessage, buildSendTimer, destroy, doStart, doStop, getComponentType, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getManagedName, getManagedType, getOverrides, getReplyChannel, getRequestChannel, isLoggingEnabled, isObserved, receive, receive, receiveMessage, receiveMessage, registerMetricsCaptor, registerObservationRegistry, registerReplyMessageCorrelatorIfNecessary, send, sendAndReceive, sendAndReceiveMessage, sendAndReceiveMessageReactive, sendTimer, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setErrorOnTimeout, setLoggingEnabled, setManagedName, setManagedType, setObservationConvention, setReceiverObservationConvention, setReplyChannel, setReplyChannelName, setReplyMapper, setReplyTimeout, setRequestChannel, setRequestChannelName, setRequestMapper, setRequestTimeout, setShouldTrackMethods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentNameMethods inherited from interface org.springframework.context.SmartLifecycle
isPauseable
-
Constructor Details
-
GrpcInboundGateway
-
-
Method Details
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classMessagingGatewaySupport
-
bindService
public io.grpc.ServerServiceDefinition bindService()- Specified by:
bindServicein interfaceio.grpc.BindableService
-