Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

Notify client of a change....

1 reply [Last post]
  • Login or register to post comments
Wed, 01/16/2013 - 22:17
TheEdge
Offline
Joined: 01/15/2013
Groups: None

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

Top
  • Login or register to post comments
Fri, 01/18/2013 - 07:52
john
Offline
Joined: 01/05/2012
Groups: None

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.

  1. K1 writes a key to C1
  2. C1 (via XDCR) sends the key to C2
  3. C2 (via XDCR) sends the key to the Nancy endpoint
  4. K2 is used inside of an IReplicationHandler subclass (see blog for details)

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...

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker