How to identify my collection name in DCP event

Hi all,

I am working on DCP Event listener…

Version:
Cocuchbase : 7.0.2
DCP : 0.37.0

Data:
Bucket: bucket
Scope: scope
Collection: collection1,collection2,collection3

Code:

final Client client = Client.builder()
.connectionString(“http://localhost”)
.credentials(“Administrator”, “123456”)
.bucket(“config_test”)
.collectionsAware(true)
.collectionNames(“scope.collection1”,“scope.collection2”,“scope.collection3”)
.build();

@Override
public void onEvent(ChannelFlowController flowController, ByteBuf event) {

}

Question :

1. How i can identify my collection in onEvent() function. On which collection this event trigger ??

Hi Bhushan,

I’m obligated to remind everyone that the java-dcp-client library is not an officially supported product. Okay, now to answer your question :slight_smile:

Collection information is available via the high level API. Instead of registering separate data and control event handlers, you register a single DatabaseChangeListener.

The mutation, deletion, and expiration events sent to the listener all extend DocumentChange which has a getCollection() method that returns info about the collection, including the name.

Thanks,
David