Class ServerRSocketMessageHandler
java.lang.Object
org.springframework.messaging.handler.invocation.reactive.AbstractMethodMessageHandler<CompositeMessageCondition>
org.springframework.messaging.handler.annotation.reactive.MessageMappingMessageHandler
org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler
org.springframework.integration.rsocket.ServerRSocketMessageHandler
- All Implemented Interfaces:
Aware,BeanNameAware,InitializingBean,ApplicationContextAware,ApplicationEventPublisherAware,EmbeddedValueResolverAware,ReactiveMessageHandler
public class ServerRSocketMessageHandler extends RSocketMessageHandler implements ApplicationEventPublisherAware
An
IntegrationRSocketMessageHandler extension for RSocket service side.
In a plain Spring Integration application instances of this class are created by the
ServerRSocketConnector internally and a new RSocket server is started over there.
When an existing RSocket server is in use, an instance of this class has to be
provided as a RSocketMessageHandler.responder() into that server and a ServerRSocketConnector
should accept the same instance as a delegate.
With a messageMappingCompatible option this class also handles
MessageMapping methods,
covering both Spring Integration and standard
RSocketMessageHandler
functionality.
- Since:
- 5.2.1
- Author:
- Artem Bilan
-
Field Summary
Fields Modifier and Type Field Description protected booleanmessageMappingCompatibleFields inherited from class org.springframework.messaging.handler.invocation.reactive.AbstractMethodMessageHandler
logger -
Constructor Summary
Constructors Constructor Description ServerRSocketMessageHandler()Create an service side RSocket message handler instance for delegating toIntegrationRSocketEndpointbeans and collectRSocketRequesters from client connections.ServerRSocketMessageHandler(boolean messageMappingCompatible)Create an service side RSocket message handler instance for delegating toIntegrationRSocketEndpointbeans and collectRSocketRequesters from client connections. -
Method Summary
Modifier and Type Method Description voidaddEndpoint(IntegrationRSocketEndpoint endpoint)booleandetectEndpoints()RSocketRequestergetClientRSocketRequester(Object key)Obtain a connectedRSocketRequestermapped by provided key or null.Map<Object,RSocketRequester>getClientRSocketRequesters()Get connectedRSocketRequesters mapped by the keys from the connect messages.protected List<? extends HandlerMethodArgumentResolver>initArgumentResolvers()protected List<? extends HandlerMethodReturnValueHandler>initReturnValueHandlers()voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)voidsetClientRSocketKeyStrategy(BiFunction<Map<String,Object>,DataBuffer,Object> clientRSocketKeyStrategy)Configure aBiFunctionto extract a key for mapping connectedRSocketRequesters.Methods inherited from class org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler
afterPropertiesSet, extendMapping, getCondition, getDefaultDataMimeType, getDefaultMetadataMimeType, getEncoders, getMetadataExtractor, getRSocketStrategies, handleNoMatch, responder, responder, setDecoders, setDefaultDataMimeType, setDefaultMetadataMimeType, setEncoders, setMetadataExtractor, setReactiveAdapterRegistry, setRouteMatcher, setRSocketStrategiesMethods inherited from class org.springframework.messaging.handler.annotation.reactive.MessageMappingMessageHandler
createExceptionMethodResolverFor, getConversionService, getDecoders, getDestination, getDirectLookupMappings, getMappingComparator, getMappingForMethod, getMatchingMapping, getRouteMatcher, getValidator, handleMatch, obtainRouteMatcher, processDestinations, registerMessagingAdvice, setConversionService, setEmbeddedValueResolver, setValidatorMethods inherited from class org.springframework.messaging.handler.invocation.reactive.AbstractMethodMessageHandler
detectHandlerMethods, getApplicationContext, getArgumentResolverConfigurer, getArgumentResolvers, getBeanName, getDestinationLookup, getHandlerMethods, getHandlerPredicate, getReactiveAdapterRegistry, getReturnValueHandlerConfigurer, handleMessage, registerExceptionHandlerAdvice, registerHandlerMethod, setApplicationContext, setArgumentResolverConfigurer, setBeanName, setHandlerPredicate, setHandlers, setReturnValueHandlerConfigurer
-
Field Details
-
messageMappingCompatible
protected final boolean messageMappingCompatible
-
-
Constructor Details
-
ServerRSocketMessageHandler
public ServerRSocketMessageHandler()Create an service side RSocket message handler instance for delegating toIntegrationRSocketEndpointbeans and collectRSocketRequesters from client connections. -
ServerRSocketMessageHandler
public ServerRSocketMessageHandler(boolean messageMappingCompatible)Create an service side RSocket message handler instance for delegating toIntegrationRSocketEndpointbeans and collectRSocketRequesters from client connections. WhenmessageMappingCompatible == true, this class also handlesMessageMappingmethods as it is done by the standardRSocketMessageHandler.- Parameters:
messageMappingCompatible- whether handle alsoMessageMapping.
-
-
Method Details
-
setClientRSocketKeyStrategy
public void setClientRSocketKeyStrategy(BiFunction<Map<String,Object>,DataBuffer,Object> clientRSocketKeyStrategy)Configure aBiFunctionto extract a key for mapping connectedRSocketRequesters. Defaults to thedestinationa client is connected.- Parameters:
clientRSocketKeyStrategy- theBiFunctionto use.
-
getClientRSocketRequesters
Get connectedRSocketRequesters mapped by the keys from the connect messages. -
getClientRSocketRequester
Obtain a connectedRSocketRequestermapped by provided key or null.- Parameters:
key- the key for mappedRSocketRequesterif any.- Returns:
- the mapped
RSocketRequesteror null.
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisherin interfaceApplicationEventPublisherAware
-
detectEndpoints
public boolean detectEndpoints() -
addEndpoint
-
initArgumentResolvers
- Overrides:
initArgumentResolversin classMessageMappingMessageHandler
-
initReturnValueHandlers
- Overrides:
initReturnValueHandlersin classRSocketMessageHandler
-