We are developing a RabbitMQ connector for Couchbase based on Couchbase Java DCP Client. Its purpose is to detect data mutation and deletions in a Couchbase Bucket and publish them in a RabbitMQ exchange.
During development we tested it against a single server cluster Community Edition, now we switched to a 3 nodes cluster EE hosted in K8s and managed by CB Operator 1.2. While testing in dev environment (single node), it never missed a mutation. Once switched to multi node setup I noticed that sometimes the mutation I expected caused some controlEvent but no dataEvents, so they where missed.
My concern was that the client was connecting to a single node and so managing data events only from the v-buckets on that node. Is this correct? Does DCP works on a per-node basis?
The client used as connection host the “headless service” created by the operator, that should list all nodes of the cluster. Now, to be sure tu have them listed, I programmatically resolve the service name in a list of addresses to use an host list in DCP client, something like that:
final InetAddress SW[] = InetAddress.getAllByName(System.getenv(Constants.COUCHBASE_CLUSTER_SERVICE));
for (int i = 0; i < SW.length; i++){
dynamicHostList.add(SW[i].getHostAddress());
}
this.client = Client.builder()
.connectionNameGenerator(DefaultConnectionNameGenerator.forProduct("rabbit-connector", "0.0.1"))
.connectTimeout(connectionTimeout)
.hostnames(dynamicHostList)
.networkResolution(networkResolution)
.bucket(bucket)
.credentials(bucketUsername, bucketPassword)
.controlParam(DcpControl.Names.ENABLE_NOOP, "true")
.compression(compressionMode)
.mitigateRollbacks(persistencePollingIntervalMillis, TimeUnit.MILLISECONDS)
.flowControl(flowControlBufferBytes)
.bufferAckWatermark(60)
.sslEnabled(false)
.build();
;
Now it seems to be realiable as in the past.
Is this a good strategy to manage client connection?