0

Linking to this question How to listen for changes to a MongoDB collection? and other similar post here; my requirement is also same: listen to MongoDB for data changes and take some action in my .NET Business layer (probably refresh data ... etc).

searching through different SO post, MongoDB documents, GitHub repository I could find that my best option is to get the required change in OPLOG using Tailable Cursor.

Other that that, I see mongo-connector which can be used to get change notification but I see target system is only solr / ElasticSearch / another MongoDB cluster.

My question: can I use mongo-connector in .NET/C# application to get change notification? Have anyone tried that? it's bit confusing and so thought of posting a question here.

If anyone have already tried, then can you provide a sample code (OR) to some resource which will provide a idea as "How to start...".

Community
  • 1
  • 1
Rahul
  • 76,197
  • 13
  • 71
  • 125

1 Answers1

0

I know this is an old question, but I try to share an idea anyway.

Note: I've only started to look into mongo-connector and its capabilities, so my knowledge is a bit limited.

Nevertheless, the mongo-connector has an extension point called DocManager, this entity has basic CRUD methods and provides a way to get notified when your domain entities changes.

So for example you can write your own DocManager. Changes you're interested in (i.e. document update) can trigger specific endpoints in your application. Or if you using some messaging in your application like RabbitMQ you can push those changes to messaging queue and implement different consumers, where each one of them will listen to specific messages.

marknorkin
  • 3,904
  • 10
  • 46
  • 82