Search code examples
azure-cosmosdbazure-cosmosdb-changefeed

CosmosDB change feed processor versioning and lease separation/handling


I'm trying to implement a change feed processor on a database called Entity, where all files are imported as "entitytype-entityid."

  1. How would I use the lease to differentiate between each type of file? It is monitoring one collection.
Entity
/id                       /partition-id
customer499                customer499
product4051                product4051
productInventory4051       productInventory4051
  1. They have also added a versioning component to this. When "customer499" is changed, the old record is changed to "customer499-[date]" and the newly imported record is added as "customer499." I only want the lease to use the new record, and the change feed to consume the new record.

I am brand new to CosmosDB and change feeds. I need each lease to start on its respective entitytype and count only that. I think I have to define these things in the delegate function I call during HandleChangesAsync but am totally stuck.


Solution

  • Change Feed Processor will listen for changes in the entire collection, across all documents and schemas stores in it, and it tracks all insert and update operations. There is currently no way for you to add a filter for specific changes.

    If you are storing multiple different schemas or want to trigger different flows based on particular document properties, it is something you need to define in the delegate.

    If you are dealing with different schemas, you can use the dynamic type to receive any type of document in the delegate and then check based on its properties which flow it needs to go to.