Class RSocketInboundGateway

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.MessagingGatewaySupport
org.springframework.integration.rsocket.inbound.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
The 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

    Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement

    org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides
  • Field Summary

    Fields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport

    messagingTemplate

    Fields inherited from class org.springframework.integration.endpoint.AbstractEndpoint

    lifecycleCondition, lifecycleLock

    Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport

    EXPRESSION_PARSER, logger

    Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement

    METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME

    Fields inherited from interface org.springframework.context.SmartLifecycle

    DEFAULT_PHASE
  • 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 void doStart()  
    RSocketInteractionModel[] getInteractionModels()
    Obtain RSocketInteractionModels this ReactiveMessageHandler is 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 void onInit()  
    void setDecodeFluxAsUnit​(boolean decodeFluxAsUnit)
    Configure an option to decode an incoming Flux as a single unit or each its event separately.
    void setInteractionModels​(RSocketInteractionModel... interactionModelsArg)
    Configure a set of RSocketInteractionModel this endpoint is mapped onto.
    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.
    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.
    void setRSocketConnector​(AbstractRSocketConnector rsocketConnector)
    Provide an AbstractRSocketConnector reference for an explicit endpoint mapping.
    void setRSocketStrategies​(org.springframework.messaging.rsocket.RSocketStrategies rsocketStrategies)
    Configure an RSocketStrategies instead 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, setShouldTrack

    Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint

    doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop

    Methods 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, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement

    getThisAs

    Methods inherited from interface org.springframework.integration.support.context.NamedComponent

    getBeanName, getComponentName
  • 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 an RSocketStrategies instead of a default one. Note: if AbstractRSocketConnector is provided, then its RSocketStrategies have a precedence.
      Parameters:
      rsocketStrategies - the RSocketStrategies to use.
      See Also:
      RSocketStrategies.builder()
    • setRSocketConnector

      public void setRSocketConnector​(AbstractRSocketConnector rsocketConnector)
      Provide an AbstractRSocketConnector reference for an explicit endpoint mapping.
      Parameters:
      rsocketConnector - the AbstractRSocketConnector to use.
    • setInteractionModels

      public void setInteractionModels​(RSocketInteractionModel... interactionModelsArg)
      Configure a set of RSocketInteractionModel this endpoint is mapped onto.
      Parameters:
      interactionModelsArg - the RSocketInteractionModels for mapping.
      Since:
      5.2.2
    • getInteractionModels

      public RSocketInteractionModel[] getInteractionModels()
      Description copied from interface: IntegrationRSocketEndpoint
      Obtain RSocketInteractionModels this ReactiveMessageHandler is going to be mapped onto. Defaults to all the RSocketInteractionModels.
      Specified by:
      getInteractionModels in interface IntegrationRSocketEndpoint
      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:
      getPath in interface IntegrationRSocketEndpoint
      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 to byte[].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 to byte[].class.
      Parameters:
      requestElementType - The payload type.
    • setDecodeFluxAsUnit

      public void setDecodeFluxAsUnit​(boolean decodeFluxAsUnit)
      Configure an option to decode an incoming Flux as a single unit or each its event separately. Defaults to false for consistency with Spring Messaging @MessageMapping. The target Flux decoding logic depends on the Decoder selected. For example a StringDecoder requires a new line separator to be present in the stream to indicate a byte buffer end.
      Parameters:
      decodeFluxAsUnit - decode incoming Flux as 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:
      onInit in class org.springframework.integration.gateway.MessagingGatewaySupport
    • doStart

      protected void doStart()
      Overrides:
      doStart in class org.springframework.integration.gateway.MessagingGatewaySupport
    • handleMessage

      public reactor.core.publisher.Mono<java.lang.Void> handleMessage​(org.springframework.messaging.Message<?> requestMessage)
      Specified by:
      handleMessage in interface org.springframework.messaging.ReactiveMessageHandler