List of usage examples for org.springframework.messaging.tcp ReconnectStrategy getTimeToNextAttempt
@Nullable
Long getTimeToNextAttempt(int attemptCount);
From source file:org.springframework.messaging.tcp.reactor.ReactorNettyTcpClient.java
private <T> Function<Flux<T>, Publisher<?>> reconnectFunction(ReconnectStrategy reconnectStrategy) { return flux -> flux.scan(1, (count, element) -> count++) .flatMap(attempt -> Optional.ofNullable(reconnectStrategy.getTimeToNextAttempt(attempt)) .map(time -> Mono.delay(Duration.ofMillis(time), this.scheduler)).orElse(Mono.empty())); }
From source file:org.springframework.messaging.tcp.reactor.ReactorTcpClient.java
@Override public ListenableFuture<Void> connect(final TcpConnectionHandler<P> connectionHandler, final ReconnectStrategy reconnectStrategy) { Assert.notNull(reconnectStrategy, "ReconnectStrategy must not be null"); Stream<TcpConnection<Message<P>, Message<P>>> stream = this.tcpClient.open(new Reconnect() { @Override/*from w w w. ja v a2s .c om*/ public Tuple2<InetSocketAddress, Long> reconnect(InetSocketAddress address, int attempt) { return Tuple.of(address, reconnectStrategy.getTimeToNextAttempt(attempt)); } }); composeConnectionHandling(stream, connectionHandler); return new PassThroughPromiseToListenableFutureAdapter<Void>(toPromise(stream)); }