Class RSocketOutboundGateway

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.AbstractMessageProducingHandler
org.springframework.integration.handler.AbstractReplyProducingMessageHandler
org.springframework.integration.rsocket.outbound.RSocketOutboundGateway
All Implemented Interfaces:
org.reactivestreams.Subscriber<org.springframework.messaging.Message<?>>, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, 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.core.Ordered, org.springframework.integration.context.ExpressionCapable, org.springframework.integration.context.Orderable, org.springframework.integration.core.MessageProducer, org.springframework.integration.handler.HeaderPropagationAware, org.springframework.integration.IntegrationPattern, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.IntegrationManagement, org.springframework.integration.support.management.TrackableComponent, org.springframework.messaging.MessageHandler, reactor.core.CoreSubscriber<org.springframework.messaging.Message<?>>

public class RSocketOutboundGateway
extends org.springframework.integration.handler.AbstractReplyProducingMessageHandler
An Outbound Messaging Gateway for RSocket requests. The request logic is fully based on the RSocketRequester, which can be obtained from the ClientRSocketConnector on the client side or from the RSocketRequesterMethodArgumentResolver.RSOCKET_REQUESTER_HEADER request message header on the server side.

An RSocket operation is determined by the configured RSocketInteractionModel or respective SpEL expression to be evaluated at runtime against the request message. By default the RSocketInteractionModel.requestResponse operation is used.

For a Publisher-based requests, it must be present in the request message payload. The flattening via upstream FluxMessageChannel will work, too, but this way we will lose a scope of particular request and every Publisher event will be send in its own plain request.

If reply is a Flux, it is wrapped to the Mono to retain a request scope. The downstream flow is responsible to obtain this Flux from a message payload and subscribe to it by itself. The Mono reply from this component is subscribed from the downstream FluxMessageChannel or it is adapted to the ListenableFuture otherwise.

Since:
5.2
See Also:
RSocketInteractionModel, RSocketRequester
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler

    org.springframework.integration.handler.AbstractReplyProducingMessageHandler.RequestHandler

    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.handler.AbstractMessageProducingHandler

    messagingTemplate

    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.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors 
    Constructor Description
    RSocketOutboundGateway​(java.lang.String route, java.lang.Object... routeVariables)
    Instantiate based on the provided RSocket endpoint route and optional variables to expand route template.
    RSocketOutboundGateway​(org.springframework.expression.Expression routeExpression)
    Instantiate based on the provided SpEL expression to evaluate an RSocket endpoint route at runtime against a request message.
  • Method Summary

    Modifier and Type Method Description
    protected void doInit()  
    protected java.lang.Object handleRequestMessage​(org.springframework.messaging.Message<?> requestMessage)  
    void setClientRSocketConnector​(ClientRSocketConnector clientRSocketConnector)
    Configure a ClientRSocketConnector for client side requests based on the connection provided by the ClientRSocketConnector.getRequester().
    void setExpectedResponseType​(java.lang.Class<?> expectedResponseType)
    Specify an response type for the RSocket response.
    void setExpectedResponseTypeExpression​(org.springframework.expression.Expression expectedResponseTypeExpression)
    Specify an Expression to determine the type for the RSocket response.
    void setInteractionModel​(RSocketInteractionModel interactionModel)
    Configure an RSocketInteractionModel for the RSocket request type.
    void setInteractionModelExpression​(org.springframework.expression.Expression interactionModelExpression)
    Configure a SpEL expression to evaluate an RSocketInteractionModel for the RSocket request type at runtime against a request message.
    void setMetadataExpression​(org.springframework.expression.Expression metadataExpression)
    Specify a SpEL expression to evaluate a metadata for the RSocket request as Map<Object, MimeType> against a request message.
    void setPublisherElementType​(java.lang.Class<?> publisherElementType)
    Configure a type for a request Publisher elements.
    void setPublisherElementTypeExpression​(org.springframework.expression.Expression publisherElementTypeExpression)
    Configure a SpEL expression to evaluate a request Publisher elements type at runtime against a request message.

    Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler

    doInvokeAdvisedRequestHandler, getBeanClassLoader, getIntegrationPatternType, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReply

    Methods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler

    addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeaders

    Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler

    handleMessage, onComplete, onError, onNext, onSubscribe

    Methods inherited from class org.springframework.integration.handler.MessageHandlerSupport

    buildSendTimer, destroy, getComponentType, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack

    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 reactor.core.CoreSubscriber

    currentContext

    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

    • RSocketOutboundGateway

      public RSocketOutboundGateway​(java.lang.String route, @Nullable java.lang.Object... routeVariables)
      Instantiate based on the provided RSocket endpoint route and optional variables to expand route template.
      Parameters:
      route - the RSocket endpoint route to use.
      routeVariables - the variables to expand route template.
    • RSocketOutboundGateway

      public RSocketOutboundGateway​(org.springframework.expression.Expression routeExpression)
      Instantiate based on the provided SpEL expression to evaluate an RSocket endpoint route at runtime against a request message. If route is a template and variables expansion is required, it is recommended to do that in this expression evaluation, for example using some bean with an appropriate logic.
      Parameters:
      routeExpression - the SpEL expression to use.
  • Method Details

    • setClientRSocketConnector

      public void setClientRSocketConnector​(ClientRSocketConnector clientRSocketConnector)
      Configure a ClientRSocketConnector for client side requests based on the connection provided by the ClientRSocketConnector.getRequester(). In case of server side, an RSocketRequester must be provided in the RSocketRequesterMethodArgumentResolver.RSOCKET_REQUESTER_HEADER header of request message.
      Parameters:
      clientRSocketConnector - the ClientRSocketConnector to use.
    • setInteractionModel

      public void setInteractionModel​(RSocketInteractionModel interactionModel)
      Configure an RSocketInteractionModel for the RSocket request type.
      Parameters:
      interactionModel - the RSocketInteractionModel to use.
      Since:
      5.2.2
    • setInteractionModelExpression

      public void setInteractionModelExpression​(org.springframework.expression.Expression interactionModelExpression)
      Configure a SpEL expression to evaluate an RSocketInteractionModel for the RSocket request type at runtime against a request message.
      Parameters:
      interactionModelExpression - the SpEL expression to use.
      Since:
      5.2.2
    • setPublisherElementType

      public void setPublisherElementType​(java.lang.Class<?> publisherElementType)
      Configure a type for a request Publisher elements.
      Parameters:
      publisherElementType - the type of the request Publisher elements.
      See Also:
      RSocketRequester.RequestSpec.data(Object, Class)
    • setPublisherElementTypeExpression

      public void setPublisherElementTypeExpression​(org.springframework.expression.Expression publisherElementTypeExpression)
      Configure a SpEL expression to evaluate a request Publisher elements type at runtime against a request message.
      Parameters:
      publisherElementTypeExpression - the expression to evaluate a type for the request Publisher elements.
      See Also:
      RSocketRequester.RequestSpec.data(java.lang.Object)
    • setExpectedResponseType

      public void setExpectedResponseType​(java.lang.Class<?> expectedResponseType)
      Specify an response type for the RSocket response.
      Parameters:
      expectedResponseType - The expected type.
      See Also:
      setExpectedResponseTypeExpression(Expression), RSocketRequester.RetrieveSpec.retrieveMono(java.lang.Class<T>), RSocketRequester.RetrieveSpec.retrieveFlux(java.lang.Class<T>)
    • setExpectedResponseTypeExpression

      public void setExpectedResponseTypeExpression​(org.springframework.expression.Expression expectedResponseTypeExpression)
      Specify an Expression to determine the type for the RSocket response.
      Parameters:
      expectedResponseTypeExpression - The expected response type expression.
      See Also:
      RSocketRequester.RetrieveSpec.retrieveMono(java.lang.Class<T>), RSocketRequester.RetrieveSpec.retrieveFlux(java.lang.Class<T>)
    • setMetadataExpression

      public void setMetadataExpression​(org.springframework.expression.Expression metadataExpression)
      Specify a SpEL expression to evaluate a metadata for the RSocket request as Map<Object, MimeType> against a request message.
      Parameters:
      metadataExpression - the expression for metadata.
    • doInit

      protected void doInit()
      Overrides:
      doInit in class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
    • handleRequestMessage

      protected java.lang.Object handleRequestMessage​(org.springframework.messaging.Message<?> requestMessage)
      Specified by:
      handleRequestMessage in class org.springframework.integration.handler.AbstractReplyProducingMessageHandler