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
rSocketMessageHandler
-
Constructor Summary
Constructors Constructor Description ServerRSocketConnector(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 providedServerRSocketMessageHandler
with 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 Type Method Description void
afterPropertiesSet()
void
afterSingletonsInstantiated()
void
destroy()
protected void
doStart()
reactor.core.publisher.Mono<Integer>
getBoundPort()
Return the port this internal server is bound or emptyMono
.RSocketRequester
getClientRSocketRequester(Object key)
Return connectedRSocketRequester
mapped by key or null.Map<Object,RSocketRequester>
getClientRSocketRequesters()
Return connectedRSocketRequester
s mapped by keys.void
setApplicationContext(ApplicationContext applicationContext)
void
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
void
setClientRSocketKeyStrategy(BiFunction<Map<String,Object>,DataBuffer,Object> clientRSocketKeyStrategy)
Configure a strategy to determine a key for the clientRSocketRequester
connected.void
setDataMimeType(MimeType dataMimeType)
Configure aMimeType
for data exchanging.void
setMetadataMimeType(MimeType metadataMimeType)
Configure aMimeType
for metadata exchanging.void
setRSocketStrategies(RSocketStrategies rsocketStrategies)
Configure aRSocketStrategies
for data encoding/decoding.void
setServerConfigurer(Consumer<io.rsocket.core.RSocketServer> serverConfigurer)
Provide aConsumer
to configure theRSocketServer
.Methods inherited from class org.springframework.integration.rsocket.AbstractRSocketConnector
addEndpoint, getDataMimeType, getMetadataMimeType, getRSocketStrategies, isAutoStartup, isRunning, setAutoStartup, setEndpoints, start, stop
-
Constructor Details
-
ServerRSocketConnector
Instantiate a server connector based on a providedServerRSocketMessageHandler
with an assumption that RSocket server is created externally as well. All other options are ignored in favor of providedServerRSocketMessageHandler
and its external RSocket server configuration.- Parameters:
serverRSocketMessageHandler
- theServerRSocketMessageHandler
to 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(ServerTransport)
-
ServerRSocketConnector
public ServerRSocketConnector(reactor.netty.http.server.HttpServer server)Instantiate a server connector based on theWebsocketServerTransport
.- Parameters:
server
- theHttpServer
to use.- See Also:
ServerRSocketConnector(ServerTransport)
-
ServerRSocketConnector
public ServerRSocketConnector(io.rsocket.transport.ServerTransport<io.rsocket.transport.netty.server.CloseableChannel> serverTransport)Instantiate a server connector based on the providedServerTransport
.- Parameters:
serverTransport
- theServerTransport
to make server based on.
-
-
Method Details
-
setServerConfigurer
Provide aConsumer
to configure theRSocketServer
.- Parameters:
serverConfigurer
- theConsumer
to 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 clientRSocketRequester
connected. Defaults to thedestination
to which a client is connected.- Parameters:
clientRSocketKeyStrategy
- theBiFunction
to determine a key for clientRSocketRequester
s.
-
setDataMimeType
Description copied from class:AbstractRSocketConnector
Configure aMimeType
for data exchanging.- Overrides:
setDataMimeType
in classAbstractRSocketConnector
- Parameters:
dataMimeType
- theMimeType
to use.
-
setMetadataMimeType
Description copied from class:AbstractRSocketConnector
Configure aMimeType
for metadata exchanging. Default to"message/x.rsocket.composite-metadata.v0"
.- Overrides:
setMetadataMimeType
in classAbstractRSocketConnector
- Parameters:
metadataMimeType
- theMimeType
to use.
-
setRSocketStrategies
Description copied from class:AbstractRSocketConnector
Configure aRSocketStrategies
for data encoding/decoding.- Overrides:
setRSocketStrategies
in classAbstractRSocketConnector
- Parameters:
rsocketStrategies
- theRSocketStrategies
to use.
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Overrides:
setApplicationContext
in classAbstractRSocketConnector
- Throws:
BeansException
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisher
in interfaceApplicationEventPublisherAware
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Overrides:
afterPropertiesSet
in classAbstractRSocketConnector
-
getClientRSocketRequesters
Return connectedRSocketRequester
s mapped by keys.- Returns:
- connected
RSocketRequester
s mapped by keys. - See Also:
ServerRSocketMessageHandler.getClientRSocketRequesters()
-
getClientRSocketRequester
Return connectedRSocketRequester
mapped by key or null.- Parameters:
key
- the mapping key.- Returns:
- the
RSocketRequester
or null. - See Also:
ServerRSocketMessageHandler.getClientRSocketRequester(Object)
-
getBoundPort
Return the port this internal server is bound or emptyMono
.- Returns:
- the port this internal server is bound or empty
Mono
if an external server is used.
-
doStart
protected void doStart()- Specified by:
doStart
in classAbstractRSocketConnector
-
destroy
public void destroy()- Specified by:
destroy
in interfaceDisposableBean
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()- Specified by:
afterSingletonsInstantiated
in interfaceSmartInitializingSingleton
- Overrides:
afterSingletonsInstantiated
in classAbstractRSocketConnector
-