Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

15. Using Nonrelational Databases > _changes: Abusing CouchDB as a Message Queu...

_changes: Abusing CouchDB as a Message Queue

CouchDB provides a change notification API (called _changes) that allows clients a great deal of flexibility in defining how to react in response to data flows.

Briefly, _changes works like so:

  1. An HTTP connection is opened to the _changes URL for the CouchDB database of interest.

  2. Wait. When any change occurs in the database in question (any document creation, deletion, or update), a JSON map is sent to the client describing the affected document ID and revision.

  3. If you have elected to be notified of changes continuously, repeat from 2.

The simplest of all _changes usage via Clojure might be using Clutch’s watch-changes function to echo all change notifications to *out*. Here, we’ll create a new database for our _changes experimentation, set up a Clutch watch function for that database, and add a few documents to see what happens:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint