Get document change notifications - Couchbase Server V4.1

Hi,

I am quite new to Couchbase DB. I read through the posts in the forum, AFAIK changes notification is only available on Couchbase-lite.
So a little background: I am developing a chat application. On my server-side, I am using the Node.js and have installed Couchbase Server V4.1.0 and am using Node.js SDK. Now I need to listen for any document changes and send out push notification to appropriate users. Can someone please tell me if there is a way to get document change notifications using Couchbase Server V4.1?

Thanks in advance!
Kirthika

There are a few ways to do this today;

  • Pooling query with an “updated_date” field periodically: you can add the field to your documents and query using N1QL or Views.
  • Use DCP (unsupported today but support coming in future): You can use DCP to grab a replication stream and get notification on all the changes. DCP is used by our internal replication, XDCR, indexing, views and backup capabilities. It is also used with out Kafka, Elasticsearch and other plugins. You get to listen in on all the changes happening in the bucket so under high mutation rate, there could be an overwhelming amount of changes. Doing complex processing on each notification may mean you may not be able to keep up but DCP is great for lightweight processing. Opening many DCP streams can overwhelm the data service as well, so if you have a large pool subscribers to DCP, it will be resource intensive to manage these. We are looking to improve these in future but for small amount of subscribers under medium mutation rates, it could provide the best option. DCP will give you a resumable and restartable change notification delivery guarantee.

thanks
-cihan

Thank you. I will explore more on these options.

How does the “update_date” work with SGW? If the device is offline, the document can come hours later.