Class ServerRSocketConnector
java.lang.Object
org.springframework.integration.rsocket.AbstractRSocketConnector
org.springframework.integration.rsocket.ServerRSocketConnector
- All Implemented Interfaces:
Aware,DisposableBean,InitializingBean,SmartInitializingSingleton,ApplicationContextAware,ApplicationEventPublisherAware,Lifecycle,Phased,SmartLifecycle
public class ServerRSocketConnector
extends AbstractRSocketConnector
implements ApplicationEventPublisherAware
A server
AbstractRSocketConnector extension to accept and manage client RSocket connections.- Since:
- 5.2
- Author:
- Artem Bilan
- See Also:
-
RSocketConnector
-
Field Summary
Fields inherited from class org.springframework.integration.rsocket.AbstractRSocketConnector
rSocketMessageHandlerFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionServerRSocketConnector(io.rsocket.transport.ServerTransport<io.rsocket.transport.netty.server.CloseableChannel> serverTransport) Instantiate a server connector based on the providedServerTransport.ServerRSocketConnector(String bindAddress, int port) Instantiate a server connector based on theTcpServerTransport.ServerRSocketConnector(ServerRSocketMessageHandler serverRSocketMessageHandler) Instantiate a server connector based on a providedServerRSocketMessageHandlerwith an assumption that RSocket server is created externally as well.ServerRSocketConnector(reactor.netty.http.server.HttpServer server) Instantiate a server connector based on theWebsocketServerTransport. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoiddestroy()protected voiddoStart()reactor.core.publisher.Mono<Integer>Return the port this internal server is bound or emptyMono.Return connectedRSocketRequestermapped by key or null.Return connectedRSocketRequesters mapped by keys.voidsetApplicationContext(ApplicationContext applicationContext) voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) voidsetClientRSocketKeyStrategy(BiFunction<Map<String, Object>, DataBuffer, Object> clientRSocketKeyStrategy) Configure a strategy to determine a key for the clientRSocketRequesterconnected.voidsetDataMimeType(MimeType dataMimeType) Configure aMimeTypefor data exchanging.voidsetMetadataMimeType(MimeType metadataMimeType) Configure aMimeTypefor metadata exchanging.voidsetRSocketStrategies(RSocketStrategies rsocketStrategies) Configure aRSocketStrategiesfor data encoding/decoding.voidsetServerConfigurer(Consumer<io.rsocket.core.RSocketServer> serverConfigurer) Provide aConsumerto configure theRSocketServer.Methods inherited from class org.springframework.integration.rsocket.AbstractRSocketConnector
addEndpoint, getDataMimeType, getMetadataMimeType, getRSocketStrategies, isAutoStartup, isRunning, setAutoStartup, setEndpoints, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.SmartLifecycle
getPhase, stop
-
Constructor Details
-
ServerRSocketConnector
Instantiate a server connector based on a providedServerRSocketMessageHandlerwith an assumption that RSocket server is created externally as well. All other options are ignored in favor of providedServerRSocketMessageHandlerand its external RSocket server configuration.- Parameters:
serverRSocketMessageHandler- theServerRSocketMessageHandlerto rely on.- Since:
- 5.2.1
-
ServerRSocketConnector
Instantiate a server connector based on theTcpServerTransport.- Parameters:
bindAddress- the local address to bind TCP server onto.port- the local TCP port to bind.- See Also:
-
ServerRSocketConnector
public ServerRSocketConnector(reactor.netty.http.server.HttpServer server) Instantiate a server connector based on theWebsocketServerTransport.- Parameters:
server- theHttpServerto use.- See Also:
-
ServerRSocketConnector
public ServerRSocketConnector(io.rsocket.transport.ServerTransport<io.rsocket.transport.netty.server.CloseableChannel> serverTransport) Instantiate a server connector based on the providedServerTransport.- Parameters:
serverTransport- theServerTransportto make server based on.
-
-
Method Details
-
setServerConfigurer
Provide aConsumerto configure theRSocketServer.- Parameters:
serverConfigurer- theConsumerto configure theRSocketServer.- Since:
- 5.2.6
-
setClientRSocketKeyStrategy
public void setClientRSocketKeyStrategy(BiFunction<Map<String, Object>, DataBuffer, Object> clientRSocketKeyStrategy) Configure a strategy to determine a key for the clientRSocketRequesterconnected. Defaults to thedestinationto which a client is connected.- Parameters:
clientRSocketKeyStrategy- theBiFunctionto determine a key for clientRSocketRequesters.
-
setDataMimeType
Description copied from class:AbstractRSocketConnectorConfigure aMimeTypefor data exchanging.- Overrides:
setDataMimeTypein classAbstractRSocketConnector- Parameters:
dataMimeType- theMimeTypeto use.
-
setMetadataMimeType
Description copied from class:AbstractRSocketConnectorConfigure aMimeTypefor metadata exchanging. Default to"message/x.rsocket.composite-metadata.v0".- Overrides:
setMetadataMimeTypein classAbstractRSocketConnector- Parameters:
metadataMimeType- theMimeTypeto use.
-
setRSocketStrategies
Description copied from class:AbstractRSocketConnectorConfigure aRSocketStrategiesfor data encoding/decoding.- Overrides:
setRSocketStrategiesin classAbstractRSocketConnector- Parameters:
rsocketStrategies- theRSocketStrategiesto use.
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware- Overrides:
setApplicationContextin classAbstractRSocketConnector- Throws:
BeansException
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisherin interfaceApplicationEventPublisherAware
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean- Overrides:
afterPropertiesSetin classAbstractRSocketConnector
-
getClientRSocketRequesters
Return connectedRSocketRequesters mapped by keys.- Returns:
- connected
RSocketRequesters mapped by keys. - See Also:
-
getClientRSocketRequester
Return connectedRSocketRequestermapped by key or null.- Parameters:
key- the mapping key.- Returns:
- the
RSocketRequesteror null. - See Also:
-
getBoundPort
Return the port this internal server is bound or emptyMono.- Returns:
- the port this internal server is bound or empty
Monoif an external server is used.
-
doStart
protected void doStart()- Specified by:
doStartin classAbstractRSocketConnector
-
destroy
public void destroy()- Specified by:
destroyin interfaceDisposableBean
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()- Specified by:
afterSingletonsInstantiatedin interfaceSmartInitializingSingleton- Overrides:
afterSingletonsInstantiatedin classAbstractRSocketConnector
-