I use couchbase 4.0.1 with Java SDK.
This is my code:
bucket.async()
.get(key)
.onErrorResumeNext(throwable -> {
if (throwable instanceof TimeoutException) {
return getBucket().async().getFromReplica(key, ReplicaMode.ALL);
}
return Observable.error(throwable);
})
.map(doc -> doc.content())
.toBlocking()
.singleOrDefault(null);
If I get TimeoutException - I go to the replica, but last week, due to a sever issue, we got OutOfMemory exception from one of our servers. Ofcourse we did not get the document from the replica and we suffered some exceptions of our own.
I'd like to know if should I go to the replica in any exception or not?
Thanks,
Ido