Announcing: Change Feed support for Azure Cosmos DB’s Cassandra API

Theo van Kraay

Azure Cosmos DB now has GA support for Change Feed for its Cassandra API. This now allows users of Azure Cosmos DB’s Cassandra API to get the same great advantages of using Change Feed as enjoyed by users of SQL (Core) API and MongoDB API.

What is Change Feed?

Azure Cosmos DB’s Change Feed is a persistent log of documents within a container. A common design pattern is to use changes to the data to trigger additional actions. Examples of additional actions include:

  • Triggering a notification or API call when an item is inserted or updated.
  • Real-time stream processing for IoT or real-time analytics processing on operational data.
  • Additional data movement by either synchronizing with a cache or a search engine or a data warehouse or archiving data to cold storage.

 

How Cassandra API Change Feed support works

Change Feed in Cassandra uses a pull model in which the Cassandra API maintains a paging state. Cassandra clients can fetch the next batch of changes using a SELECT statement and the previous paging state. The C# snippet below defines a query on the change feed, starting at current datetime:

DateTime timeBegin = DateTime.UtcNow;
string time = timeBegin.ToString("yyyy-MM-ddTHH:mm:ss.fffZ", CultureInfo.InvariantCulture);

//Return the latest change for all rows in 'user' table
IStatement changeFeedQueryStatement = new SimpleStatement(
$"SELECT * FROM uprofile.user where COSMOS_CHANGEFEED_START_TIME() = '{time}'");

The below demo shows the Change Feed being queried iteratively, using the paging state, while another application is writing records to the same table. In each iteration, the query resumes at the last point changes were read. As a result, we see a continuous stream of new changes available on the change feed. You can download the full code sample here.

 

The current version of the pull-based change feed model for Cassandra API supports change tracking on either a per logical partition key (primary key) basis, or on the entire container. Please note: for large scale implementations, the use of Change Feed should be run in parallel across partitions.

More changes and enhancements to follow soon!

Get started

Create a new account using the Azure Portal, ARM template or Azure CLI and connect to it using your favorite tools. We’d love to hear your feedback as well at askcosmosdbcassandra@microsoft.com

Stay up-to-date on the latest Azure #CosmosDB news and features by following us on Twitter @AzureCosmosDB. We are really excited to see what you will build with Azure Cosmos DB!

About Azure Cosmos DB

Azure Cosmos DB is a globally distributed, multi-model database service that enables you to read and write data from any Azure region. It offers turnkey global distribution, guarantees single-digit millisecond latency at the 99th percentile, 99.999 percent high availability, with elastic scaling of throughput and storage.

0 comments

Discussion is closed.

Feedback usabilla icon