Couchbase java sdk migration bucket insert issue from 1.4.4 to 2.5


HI Couchbase Team,
I am migrating the couchbase jdk code from 1.4.4 to 2.5.

1.4.4 bucket insert method looks like:
public void setRIObject(String key,String data){
OperationFuture ri = client.set(key, expiry,data);
}catch(Exception ex){
int retry = 1;
int cbRetryLimit= 5;
while(retry < cbRetryLimit){
logger.error("Retrying [{}] inserting for id [{}] ",retry,key);
OperationFuture ric = setObject(cbClient.getRIClient(), key, data);
}catch(Exception e){
if(retry == cbRetryLimit){
logger.error(“Failed after the maximum retry [{}] with Exception [{}]”,retry,ExceptionUtils.getFullStackTrace(e));

Kindly let me know in 2.5 version, how can i get the OperationFuture out of the bucket insert method and also how can i apply the retry logic in case of exception


This is roughly covered in the (now very old) migrating from Java SDK 1.4.x to 2.x documentation.

Since you mention retry logic, I would encourage you to have a look at the current async documentation section which talks about RxJava Observables and then maybe the older Mastering Observables section. Much of the error handling logic is in RxJava.

The answer can vary, but it may make more sense to move to observables rather than try to wrap everything into the Future<T> interface.