Notify client of a change....
Wed, 01/16/2013 - 22:17
Hi,
Environment: C# Winforms, SDK 1.2
I am new to Couchbase so I may have missed something. What I want to achieve is a push notification to a client(s) when a document updates after being replicated by XDCR. My use case is as follows:
- Two clusters (CL1, CL2) with a single node in each
- Two clients (K1, K2) such that K1 connected to CL1, K2 connected to CL2
- K1 makes a change to DocA
- DocA is replicated via XDCR from CL1 --> CL2
- Once DocA is in CL2 client K2 is notified
Is this something that the Observe() method can do or is there another approach?
--D
The client is not aware of XDCR replication and it does not have any hooks into XDCR events. So unfortunately, there's no way for a client instance to know that a key was replicated to its cluster.
Assuming that K2 needs to operate on data that's been replicated to C2, an (admittedly untested) alternative would be to have C2 replicate to an ASP.NET endpoint. In this case, you could use the Nancy endpoint I recently wrote - http://blog.couchbase.com/xdcr-aspnet-and-nancy.
So basically, after C1 XDCR replicates to C2, you push from C2 to your app, which would have XDCR endpoints defined, either via Nancy or by copying the code from my Nancy app into your existing web app. The endpoint host isn't important, but the URIs (e.g., /pools) and JSON responses are. Again, the idea here is that you're treating the K2 app as a third XDCR endpoint, but one that receives its keys only after C2 gets them from C1.
Observe is used to specify durability requirements when storing or removing keys. For example, you could ask the client to consider a store operation successful if and only if a key was persisted to its master node and replicated (in memory or disk) to two replica nodes. http://www.couchbase.com/docs/couchbase-sdk-net-1.2/couchbase-sdk-net-st...