Class RSocketOutboundGateway
- All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>
,Aware
,BeanClassLoaderAware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Ordered
,ExpressionCapable
,Orderable
,MessageProducer
,HeaderPropagationAware
,IntegrationPattern
,NamedComponent
,IntegrationManagement
,TrackableComponent
,MessageHandler
,reactor.core.CoreSubscriber<Message<?>>
public class RSocketOutboundGateway extends AbstractReplyProducingMessageHandler
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
- Author:
- Artem Bilan
- See Also:
RSocketInteractionModel
,RSocketRequester
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
AbstractReplyProducingMessageHandler.RequestHandler
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
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(String route, Object... routeVariables)
Instantiate based on the provided RSocket endpointroute
and optional variables to expand route template.RSocketOutboundGateway(Expression routeExpression)
Instantiate based on the provided SpEL expression to evaluate an RSocket endpointroute
at runtime against a request message. -
Method Summary
Modifier and Type Method Description protected void
doInit()
protected Object
handleRequestMessage(Message<?> requestMessage)
Subclasses must implement this method to handle the request Message.void
setClientRSocketConnector(ClientRSocketConnector clientRSocketConnector)
Configure aClientRSocketConnector
for client side requests based on the connection provided by theClientRSocketConnector.getRequester()
.void
setExpectedResponseType(Class<?> expectedResponseType)
Specify an response type for the RSocket response.void
setExpectedResponseTypeExpression(Expression expectedResponseTypeExpression)
Specify anExpression
to determine the type for the RSocket response.void
setInteractionModel(RSocketInteractionModel interactionModel)
Configure anRSocketInteractionModel
for the RSocket request type.void
setInteractionModelExpression(Expression interactionModelExpression)
Configure a SpEL expression to evaluate anRSocketInteractionModel
for the RSocket request type at runtime against a request message.void
setMetadataExpression(Expression metadataExpression)
Specify a SpEL expression to evaluate a metadata for the RSocket request asMap<Object, MimeType>
against a request message.void
setPublisherElementType(Class<?> publisherElementType)
Configure a type for a requestPublisher
elements.void
setPublisherElementTypeExpression(Expression publisherElementTypeExpression)
Configure a SpEL expression to evaluate a requestPublisher
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 org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
RSocketOutboundGateway
Instantiate based on the provided RSocket endpointroute
and optional variables to expand route template.- Parameters:
route
- the RSocket endpoint route to use.routeVariables
- the variables to expand route template.
-
RSocketOutboundGateway
Instantiate based on the provided SpEL expression to evaluate an RSocket endpointroute
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
Configure aClientRSocketConnector
for client side requests based on the connection provided by theClientRSocketConnector.getRequester()
. In case of server side, anRSocketRequester
must be provided in theRSocketRequesterMethodArgumentResolver.RSOCKET_REQUESTER_HEADER
header of request message.- Parameters:
clientRSocketConnector
- theClientRSocketConnector
to use.
-
setInteractionModel
Configure anRSocketInteractionModel
for the RSocket request type.- Parameters:
interactionModel
- theRSocketInteractionModel
to use.- Since:
- 5.2.2
-
setInteractionModelExpression
Configure a SpEL expression to evaluate anRSocketInteractionModel
for the RSocket request type at runtime against a request message.- Parameters:
interactionModelExpression
- the SpEL expression to use.- Since:
- 5.2.2
-
setPublisherElementType
Configure a type for a requestPublisher
elements.- Parameters:
publisherElementType
- the type of the requestPublisher
elements.- See Also:
RSocketRequester.RequestSpec.data(Object, Class)
-
setPublisherElementTypeExpression
Configure a SpEL expression to evaluate a requestPublisher
elements type at runtime against a request message.- Parameters:
publisherElementTypeExpression
- the expression to evaluate a type for the requestPublisher
elements.- See Also:
RSocketRequester.RequestSpec.data(java.lang.Object)
-
setExpectedResponseType
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
Specify anExpression
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
Specify a SpEL expression to evaluate a metadata for the RSocket request asMap<Object, MimeType>
against a request message.- Parameters:
metadataExpression
- the expression for metadata.
-
doInit
protected void doInit()- Overrides:
doInit
in classAbstractReplyProducingMessageHandler
-
handleRequestMessage
Description copied from class:AbstractReplyProducingMessageHandler
Subclasses must implement this method to handle the request Message. The return value may be a Message, a MessageBuilder, or any plain Object. The base class will handle the final creation of a reply Message from any of those starting points. If the return value is null, the Message flow will end here.- Specified by:
handleRequestMessage
in classAbstractReplyProducingMessageHandler
- Parameters:
requestMessage
- The request message.- Returns:
- The result of handling the message, or
null
.
-