I want to have two types of retry connection with different delay (I use Redis running on Kubernetes and jedis clinet).It is possible to do it like this, and use retryWhen
two times in the same block? If not, how to do it? A unit tests provide me, that is not working correctly (I think only first retryWhen
is called, but second not). Where is the bug?
public Observable<String> getMessagesFromChannel(String channel) { return PublishSubject.<String>fromPublisher( subscriber -> config.executor().execute(() -> bindRedisSubscriptionToPublisher(channel,subscriber))) .retryWhen(t -> t.take(config.numberOfReconnectWhenNetworkIsBreak()).delay(1, TimeUnit.SECONDS)) .doOnError(ex -> log.trace("Trying to subscribe " + config.numberOfReconnect() +" times without success")) .retryWhen( ts -> ts.doOnEach( ex -> { log.warn("Redis instance down. Error while subscribing, trying to reconnect in {} ms", config.reconnectTimeAfterRedisInstanceDown().toMillis(), ex.getValue()); }) .delay(config.reconnectTimeAfterRedisInstanceDown().toMillis(), MILLISECONDS, config.scheduler())); }