Class ServerRSocketMessageHandler

java.lang.Object
org.springframework.messaging.handler.invocation.reactive.AbstractMethodMessageHandler<org.springframework.messaging.handler.CompositeMessageCondition>
org.springframework.messaging.handler.annotation.reactive.MessageMappingMessageHandler
org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler
org.springframework.integration.rsocket.ServerRSocketMessageHandler
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationEventPublisherAware, org.springframework.context.EmbeddedValueResolverAware, org.springframework.messaging.ReactiveMessageHandler

public class ServerRSocketMessageHandler extends org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler implements org.springframework.context.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
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final boolean
     

    Fields inherited from class org.springframework.messaging.handler.invocation.reactive.AbstractMethodMessageHandler

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an service side RSocket message handler instance for delegating to IntegrationRSocketEndpoint beans and collect RSocketRequesters from client connections.
    ServerRSocketMessageHandler(boolean messageMappingCompatible)
    Create an service side RSocket message handler instance for delegating to IntegrationRSocketEndpoint beans and collect RSocketRequesters from client connections.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    boolean
     
    org.springframework.messaging.rsocket.RSocketRequester
    Obtain a connected RSocketRequester mapped by provided key or null.
    Map<Object,org.springframework.messaging.rsocket.RSocketRequester>
    Get connected RSocketRequesters mapped by the keys from the connect messages.
    protected List<? extends org.springframework.messaging.handler.invocation.reactive.HandlerMethodArgumentResolver>
     
    protected List<? extends org.springframework.messaging.handler.invocation.reactive.HandlerMethodReturnValueHandler>
     
    void
    setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
     
    void
    setClientRSocketKeyStrategy(BiFunction<Map<String,Object>,org.springframework.core.io.buffer.DataBuffer,Object> clientRSocketKeyStrategy)
    Configure a BiFunction to extract a key for mapping connected RSocketRequesters.

    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, setRSocketStrategies

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

    Methods 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • messageMappingCompatible

      protected final boolean messageMappingCompatible
  • Constructor Details

    • ServerRSocketMessageHandler

      public ServerRSocketMessageHandler()
      Create an service side RSocket message handler instance for delegating to IntegrationRSocketEndpoint beans and collect RSocketRequesters from client connections.
    • ServerRSocketMessageHandler

      public ServerRSocketMessageHandler(boolean messageMappingCompatible)
      Create an service side RSocket message handler instance for delegating to IntegrationRSocketEndpoint beans and collect RSocketRequesters from client connections. When messageMappingCompatible == true, this class also handles MessageMapping methods as it is done by the standard RSocketMessageHandler.
      Parameters:
      messageMappingCompatible - whether handle also MessageMapping.
  • Method Details

    • setClientRSocketKeyStrategy

      public void setClientRSocketKeyStrategy(BiFunction<Map<String,Object>,org.springframework.core.io.buffer.DataBuffer,Object> clientRSocketKeyStrategy)
      Configure a BiFunction to extract a key for mapping connected RSocketRequesters. Defaults to the destination a client is connected.
      Parameters:
      clientRSocketKeyStrategy - the BiFunction to use.
    • getClientRSocketRequesters

      public Map<Object,org.springframework.messaging.rsocket.RSocketRequester> getClientRSocketRequesters()
      Get connected RSocketRequesters mapped by the keys from the connect messages.
      Returns:
      the map of connected RSocketRequesters.
      See Also:
    • getClientRSocketRequester

      @Nullable public org.springframework.messaging.rsocket.RSocketRequester getClientRSocketRequester(Object key)
      Obtain a connected RSocketRequester mapped by provided key or null.
      Parameters:
      key - the key for mapped RSocketRequester if any.
      Returns:
      the mapped RSocketRequester or null.
    • setApplicationEventPublisher

      public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
      Specified by:
      setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware
    • detectEndpoints

      public boolean detectEndpoints()
    • addEndpoint

      public void addEndpoint(IntegrationRSocketEndpoint endpoint)
    • initArgumentResolvers

      protected List<? extends org.springframework.messaging.handler.invocation.reactive.HandlerMethodArgumentResolver> initArgumentResolvers()
      Overrides:
      initArgumentResolvers in class org.springframework.messaging.handler.annotation.reactive.MessageMappingMessageHandler
    • initReturnValueHandlers

      protected List<? extends org.springframework.messaging.handler.invocation.reactive.HandlerMethodReturnValueHandler> initReturnValueHandlers()
      Overrides:
      initReturnValueHandlers in class org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler