public class RSocketConnector extends Object
| Modifier and Type | Method and Description |
|---|---|
RSocketConnector |
acceptor(SocketAcceptor acceptor) |
Mono<RSocket> |
connect(ClientTransport transport) |
Mono<RSocket> |
connect(Supplier<ClientTransport> transportSupplier) |
static Mono<RSocket> |
connectWith(ClientTransport transport) |
static RSocketConnector |
create() |
RSocketConnector |
dataMimeType(String dataMimeType) |
RSocketConnector |
errorConsumer(Consumer<Throwable> errorConsumer)
Deprecated.
this is deprecated with no replacement and will be removed after
RSocketFactory is removed. |
RSocketConnector |
fragment(int mtu) |
RSocketConnector |
interceptors(Consumer<InterceptorRegistry> consumer) |
RSocketConnector |
keepAlive(Duration interval,
Duration maxLifeTime)
Set the time
interval between KEEPALIVE frames sent by this client, and the maxLifeTime that this client will allow between KEEPALIVE frames from the server before
assuming it is dead. |
RSocketConnector |
lease(Supplier<Leases<? extends LeaseStats>> supplier) |
RSocketConnector |
metadataMimeType(String metadataMimeType) |
RSocketConnector |
payloadDecoder(PayloadDecoder payloadDecoder) |
RSocketConnector |
reconnect(Retry retrySpec)
Enables a reconnectable, shared instance of
Mono<RSocket> so every subscriber will
observe the same RSocket instance up on connection establishment. |
RSocketConnector |
resume(Resume resume) |
RSocketConnector |
setupPayload(Payload payload) |
public static RSocketConnector create()
public static Mono<RSocket> connectWith(ClientTransport transport)
public RSocketConnector setupPayload(Payload payload)
public RSocketConnector dataMimeType(String dataMimeType)
public RSocketConnector metadataMimeType(String metadataMimeType)
public RSocketConnector interceptors(Consumer<InterceptorRegistry> consumer)
public RSocketConnector acceptor(SocketAcceptor acceptor)
public RSocketConnector keepAlive(Duration interval, Duration maxLifeTime)
interval between KEEPALIVE frames sent by this client, and the maxLifeTime that this client will allow between KEEPALIVE frames from the server before
assuming it is dead.
Note that reasonable values for the time interval may vary significantly. For
server-to-server connections the spec suggests 500ms, while for for mobile-to-server
connections it suggests 30+ seconds. In addition maxLifeTime should allow plenty of
room for multiple missed ticks from the server.
By default interval is set to 20 seconds and maxLifeTime to 90 seconds.
interval - the time between KEEPALIVE frames sent, must be greater than 0.maxLifeTime - the max time between KEEPALIVE frames received, must be greater than 0.public RSocketConnector reconnect(Retry retrySpec)
Mono<RSocket> so every subscriber will
observe the same RSocket instance up on connection establishment.
Mono<RSocket> sharedRSocketMono =
RSocketConnector.create()
.reconnect(Retry.fixedDelay(3, Duration.ofSeconds(1)))
.connect(transport);
RSocket r1 = sharedRSocketMono.block();
RSocket r2 = sharedRSocketMono.block();
assert r1 == r2;
Apart of the shared behavior, if the connection is lost, the same Mono<RSocket>
instance will transparently re-establish the connection for subsequent subscribers.
Mono<RSocket> sharedRSocketMono =
RSocketConnector.create()
.reconnect(Retry.fixedDelay(3, Duration.ofSeconds(1)))
.connect(transport);
RSocket r1 = sharedRSocketMono.block();
RSocket r2 = sharedRSocketMono.block();
assert r1 == r2;
r1.dispose()
assert r2.isDisposed()
RSocket r3 = sharedRSocketMono.block();
RSocket r4 = sharedRSocketMono.block();
assert r1 != r3;
assert r4 == r3;
Note, having reconnect() enabled does not eliminate the need to accompany each
individual request with the corresponding retry logic.
Mono<RSocket> sharedRSocketMono =
RSocketConnector.create()
.reconnect(Retry.fixedDelay(3, Duration.ofSeconds(1)))
.connect(transport);
sharedRSocket.flatMap(rSocket -> rSocket.requestResponse(...))
.retryWhen(ownRetry)
.subscribe()
retrySpec - a retry factory applied for Mono.retryWhen(Retry)Mono<RSocket>.public RSocketConnector resume(Resume resume)
public RSocketConnector lease(Supplier<Leases<? extends LeaseStats>> supplier)
public RSocketConnector fragment(int mtu)
public RSocketConnector payloadDecoder(PayloadDecoder payloadDecoder)
@Deprecated public RSocketConnector errorConsumer(Consumer<Throwable> errorConsumer)
RSocketFactory is removed.public Mono<RSocket> connect(ClientTransport transport)
public Mono<RSocket> connect(Supplier<ClientTransport> transportSupplier)