question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support multiple ChangeFeed handlers for a single container

See original GitHub issue

Is your feature request related to a problem? Please describe. In situations when you keep different types of documents in a single container you have a problem with change feed processor builder. Let me explain. Currently, you can build change feed processor like this:

var changeFeedProcessor = database
	.GetContainer("MyContainer")
	.GetChangeFeedProcessorBuilder("MyContainerChangeFeed", HandleChangesAsync)
        ...
        .Build();

where HandleChangesAsync has a type of ChangesHandler<T>. Here I have a problem. The type T here should be a type of a document which I want to feed. It works great if I have only one type of documents in the container. If I have more than one type of documents the only way how to deal with it is to use dynamic type and create handler which will manually parse the change object as JSON and cast it to the correct type. It saves me a lot of time and make code much cleaner if I can attach multiple handlers to the single container in the change feed processor builder.

Describe the solution you’d like It would be great to have API like this:

ChangesHandler<DocumentType1> HandleChangesAsync1 = (changes, token) => { ... };
ChangesHandler<DocumentType2> HandleChangesAsync2 = (changes, token) => { ... };

var changeFeedProcessor = database
	.GetContainer("MyContainer")
	.GetChangeFeedProcessorBuilder("MyContainerChangeFeed")
        .WithHandler(HandleChangesAsync1)
        .WithHandler(HandleChangesAsync2)
        ...
        .Build();

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Ceridancommented, Oct 16, 2019

Yes, sounds fair. I think we may close this issue, you answered to all my questions. Thank you for the explanation and for your time.

0reactions
ealsurcommented, Oct 16, 2019

In order to support the Type pattern effectively and without a compute bottle beck, this would need to work as a backend filter, where you could just read the Change Feed for a particular subsets of documents (for example, where Type = Something). That is not possible currently and I’m not aware of any roadmap for it.

If it’s a feature that would need to be implemented in the client SDK, then it would simply do the same you are currently doing, basically take the List of documents and apply a filtering mechanism. I have not yet seen any other request for this in the repo, my guess is because it’s something that would be nice in the Type pattern scenario, but it’s not a blocker because it’s simple to implement and it doesn’t add any value to any other scenario.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - How to handle changes from different containers in ...
I'm trying to implement builder/factory for Change Feed Processor ... is possible to handle changes for all containers in one application.
Read more >
Change feed processor in Azure Cosmos DB
A single change feed processor deployment unit consists of one or more compute instances that have the same value for processorName and the...
Read more >
Lessons learned from an Azure Cosmos DB change feed ...
Change feed support in Azure Cosmos DB works by listening to an Azure Cosmos DB container for any changes. It then outputs the...
Read more >
Implementing Cosmos DB Change Feed using Azure ...
If you have a large container, the Change Feed can be processed by multiple consumers and we can have multiple Change Feeds on...
Read more >
Azure Cosmos DB Change Feed
One of the interesting features of Azure Cosmos DB is its change feed. The change feed provides support for many scenarios, three of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found