Class RSocketInboundGateway
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle,org.springframework.integration.context.ExpressionCapable,org.springframework.integration.IntegrationPattern,IntegrationRSocketEndpoint,org.springframework.integration.support.context.NamedComponent,org.springframework.integration.support.management.IntegrationInboundManagement,org.springframework.integration.support.management.IntegrationManagement,org.springframework.integration.support.management.ManageableLifecycle,org.springframework.integration.support.management.ManageableSmartLifecycle,org.springframework.integration.support.management.TrackableComponent,org.springframework.messaging.ReactiveMessageHandler
public class RSocketInboundGateway extends org.springframework.integration.gateway.MessagingGatewaySupport implements IntegrationRSocketEndpoint
MessagingGatewaySupport implementation for the IntegrationRSocketEndpoint.
Represents an inbound endpoint for RSocket requests.
May be configured with the AbstractRSocketConnector for mapping registration.
Or existing AbstractRSocketConnector bean(s) will perform detection automatically.
An inbound DataBuffer (either single or as a Publisher element) is
converted to the target expected type which can be configured by the
setRequestElementClass(java.lang.Class<?>) or setRequestElementType(ResolvableType).
If it is not configured, then target type is determined by the contentType header:
If it is a text, then target type is String, otherwise - byte[].
An inbound Publisher is used as is in the message to send payload.
It is a target application responsibility to process that payload any possible way.
A reply payload is encoded to the Flux according a type of the payload or a
Publisher element type.
- Since:
- 5.2
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
messagingTemplateFields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger -
Constructor Summary
Constructors Constructor Description RSocketInboundGateway(java.lang.String... pathArg)Instantiate based on the provided path patterns to map this endpoint for incoming RSocket requests. -
Method Summary
Modifier and Type Method Description protected voiddoStart()RSocketInteractionModel[]getInteractionModels()ObtainRSocketInteractionModels thisReactiveMessageHandleris going to be mapped onto.java.lang.String[]getPath()Get an array of the path patterns this endpoint is mapped onto.reactor.core.publisher.Mono<java.lang.Void>handleMessage(org.springframework.messaging.Message<?> requestMessage)protected voidonInit()voidsetDecodeFluxAsUnit(boolean decodeFluxAsUnit)Configure an option to decode an incomingFluxas a single unit or each its event separately.voidsetInteractionModels(RSocketInteractionModel... interactionModelsArg)Configure a set ofRSocketInteractionModelthis endpoint is mapped onto.voidsetRequestElementClass(java.lang.Class<?> requestElementClass)Specify a type of payload to be generated when the inbound RSocket request content is read by the encoders.voidsetRequestElementType(org.springframework.core.ResolvableType requestElementType)Specify the type of payload to be generated when the inbound RSocket request content is read by the converters/encoders.voidsetRSocketConnector(AbstractRSocketConnector rsocketConnector)Provide anAbstractRSocketConnectorreference for an explicit endpoint mapping.voidsetRSocketStrategies(org.springframework.messaging.rsocket.RSocketStrategies rsocketStrategies)Configure anRSocketStrategiesinstead of a default one.Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
buildErrorMessage, buildSendTimer, destroy, doStop, getComponentType, getErrorChannel, getErrorMessageAttributes, getIntegrationPatternType, getManagedName, getManagedType, getOverrides, getReplyChannel, getRequestChannel, isLoggingEnabled, receive, receive, receiveMessage, receiveMessage, registerMetricsCaptor, registerReplyMessageCorrelatorIfNecessary, send, sendAndReceive, sendAndReceiveMessage, sendAndReceiveMessageReactive, sendTimer, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setErrorOnTimeout, setLoggingEnabled, setManagedName, setManagedType, 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, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
RSocketInboundGateway
public RSocketInboundGateway(java.lang.String... pathArg)Instantiate based on the provided path patterns to map this endpoint for incoming RSocket requests.- Parameters:
pathArg- the mapping patterns to use.
-
-
Method Details
-
setRSocketStrategies
public void setRSocketStrategies(org.springframework.messaging.rsocket.RSocketStrategies rsocketStrategies)Configure anRSocketStrategiesinstead of a default one. Note: ifAbstractRSocketConnectoris provided, then itsRSocketStrategieshave a precedence.- Parameters:
rsocketStrategies- theRSocketStrategiesto use.- See Also:
RSocketStrategies.builder()
-
setRSocketConnector
Provide anAbstractRSocketConnectorreference for an explicit endpoint mapping.- Parameters:
rsocketConnector- theAbstractRSocketConnectorto use.
-
setInteractionModels
Configure a set ofRSocketInteractionModelthis endpoint is mapped onto.- Parameters:
interactionModelsArg- theRSocketInteractionModels for mapping.- Since:
- 5.2.2
-
getInteractionModels
Description copied from interface:IntegrationRSocketEndpointObtainRSocketInteractionModels thisReactiveMessageHandleris going to be mapped onto. Defaults to all theRSocketInteractionModels.- Specified by:
getInteractionModelsin interfaceIntegrationRSocketEndpoint- Returns:
- the interaction models for mapping.
-
getPath
public java.lang.String[] getPath()Get an array of the path patterns this endpoint is mapped onto.- Specified by:
getPathin interfaceIntegrationRSocketEndpoint- Returns:
- the mapping path
-
setRequestElementClass
public void setRequestElementClass(java.lang.Class<?> requestElementClass)Specify a type of payload to be generated when the inbound RSocket request content is read by the encoders. By default this value is null which means at runtime any "text" Content-Type will result in String while all others default tobyte[].class.- Parameters:
requestElementClass- The payload type.
-
setRequestElementType
public void setRequestElementType(org.springframework.core.ResolvableType requestElementType)Specify the type of payload to be generated when the inbound RSocket request content is read by the converters/encoders. By default this value is null which means at runtime any "text" Content-Type will result in String while all others default tobyte[].class.- Parameters:
requestElementType- The payload type.
-
setDecodeFluxAsUnit
public void setDecodeFluxAsUnit(boolean decodeFluxAsUnit)Configure an option to decode an incomingFluxas a single unit or each its event separately. Defaults tofalsefor consistency with Spring Messaging@MessageMapping. The targetFluxdecoding logic depends on theDecoderselected. For example aStringDecoderrequires a new line separator to be present in the stream to indicate a byte buffer end.- Parameters:
decodeFluxAsUnit- decode incomingFluxas a single unit or each event separately.- Since:
- 5.3
- See Also:
Decoder.decode(Publisher, ResolvableType, MimeType, java.util.Map)
-
onInit
protected void onInit()- Overrides:
onInitin classorg.springframework.integration.gateway.MessagingGatewaySupport
-
doStart
protected void doStart()- Overrides:
doStartin classorg.springframework.integration.gateway.MessagingGatewaySupport
-
handleMessage
public reactor.core.publisher.Mono<java.lang.Void> handleMessage(org.springframework.messaging.Message<?> requestMessage)- Specified by:
handleMessagein interfaceorg.springframework.messaging.ReactiveMessageHandler
-