Spring data Couchbase Multiple Bucket java.util.concurrent.TimeoutException

connections
java

#1

Hi,

I’m trying to connect to multiple buckets in my Spring boot data Couchbase application. I referred to the below link to configure multiple buckets.
https://www.baeldung.com/spring-data-couchbase-buckets-and-spatial-view-queries.

Below is the code written in “CouchbaseServerConfig” class.

//  Multiple Bucket configuration

@Bean
public Bucket bundlingMapBucket() throws Exception {
    return couchbaseCluster().openBucket("BundlingMapDoc", "Password");
}


@Bean
public CouchbaseTemplate bundlingMapTemplate() throws Exception {
    CouchbaseTemplate template = new CouchbaseTemplate(
        couchbaseClusterInfo(), bundlingMapBucket(),
        mappingCouchbaseConverter(), translationService());
    template.setDefaultConsistency(getDefaultConsistency());
    return template;
}


@Override
public void configureRepositoryOperationsMapping(
    RepositoryOperationsMapping baseMapping) {
    try {
//            Thread.sleep( 1000L );
        baseMapping.mapEntity(BundleMapEntity.class, bundlingMapTemplate());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Tried increasing the “Time”, used Thread.sleep. Nothing worked. Could anyone please tell what other configuration do I’ve to do to connect to multiple buckets.

Exception:

Caused by: java.lang.RuntimeException: java.util.concurrent.TimeoutException
at com.couchbase.client.core.utils.Blocking.blockForSingle(Blocking.java:74)
at com.couchbase.client.java.CouchbaseCluster.openBucket(CouchbaseCluster.java:344)
at com.couchbase.client.java.CouchbaseCluster.openBucket(CouchbaseCluster.java:328)
at com.couchbase.client.java.CouchbaseCluster.openBucket(CouchbaseCluster.java:317)
at com.aexp.global.cmpreference.repository.config.CouchbaseServerConfig.bundlingMapBucket(CouchbaseServerConfig.java:77)
at com.aexp.global.cmpreference.repository.config.CouchbaseServerConfig$$EnhancerBySpringCGLIB$$bf2bffa3.CGLIB$bundlingMapBucket$3(<generated>)
at com.aexp.global.cmpreference.repository.config.CouchbaseServerConfig$$EnhancerBySpringCGLIB$$bf2bffa3$$FastClassBySpringCGLIB$$865fca6.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
at com.aexp.global.cmpreference.repository.config.CouchbaseServerConfig$$EnhancerBySpringCGLIB$$bf2bffa3.bundlingMapBucket(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 150 more
Caused by: java.util.concurrent.TimeoutException