Notifications with CouchDB using C# - c#

I want to implement with C# a CouchDB client to push notifications when documents from a CouchDB view are changed, i.e. monitor views.
There are several CouchDB api attempts SharpChouch, Relax-Net but nothing has been done around notifications. Is this even possible to implement with CouchDB or I'm missing something?

Yes, that's possible. You need to take a looks at _changes handler. Additionally you can filter changes using filter functions.
CouchDB. The Defenitive Guide: Change Notifications

You have the asynchronous C# client MyCouch, which has documentation on how to consume the Changes API: https://github.com/danielwertheim/mycouch/wiki/documentation#consume-the-changes-feed
Note. There are two NuGet packages. One that is for CouchDb and one for Cloudant, that offers Cloudant specific features.

Related

Listening to updates to activities in serverside C# code

I'm experimenting with the getstream.io service, and evaluating if it fits our use case. Basically what I would like to to is for one server side service to add activity to a feed, and then for another server side code to subscribe to changes to that feed, and receive them in real time. Both should be in C# ideally.
Is this possible at all?
Definitely possible, you can add a webhook from the dashboard which will get the update as soon as there is a change in the feed.
If you're on AWS, you can copy updates to your SQS.
Moreover, Faye is also used for real-time updates. You can find a client for it in C# but it won't officially be supported (we're supporting it in JS SDK for example).

REST and DocumentDB

I am creating a Xamarin Android application and I want to use DocumentDB, but unfortunately it's impossible to use Microsoft.Azure.DocumentDB NuGet package, and it seems the only way is to use REST.
How can I use REST for receiving, updating, adding data to DocumentDB with C#?
There is a giant knowledge base about this. You should read it:
https://msdn.microsoft.com/en-us/library/azure/dn781481.aspx
They are also referencing a Github repository that contains examples on how to interact with that REST interface. It's really easy. Just start out by copying chunks of the code and adjust them to your needs:
https://github.com/Azure/azure-documentdb-dotnet/tree/master/samples/rest-from-.net
The code is well commented and explains all the steps in detail.

Change notification in MongoDB:using mongo-connector

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...".
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.

How to use SignalR for autorefresh like data

I've been looking into using SignalR for a while now, and I think I have a good candidate for it.
I have a page which allows users of the system to leave Comments, and at the moment it uses JQuery to periodically refresh the list of comments. I think SignalR would replace this nicely, i.e. if there were two users looking at the list and one wrote a comment, I would like it to appear instantly in the second.
All well and good, I have a sort of template where this works.
However
My system itself can sometimes add automatic notifications to the list - These are put into the database directly by a non-web based application.
How can I get SignalR to see the new information from the database and send it to the users?
In SignalR the hub is a static part in your application. You can spin up a System.Threading.Timer in your webapplication to periodically check your database for new notifications and add those to the data used by the hub.
This can even be improved by using a SqlCacheDependency.
A subjective side note: I do agree this type of functionality is a very good candidate for SignalR.

data driven (real-time) Web frontend

We are looking into a better way to deliver data update notifications to a web front end.
These notifications trigger events that execute business logic and up-date elements via JavaScript (JS) to dynamically update the page without reloading.
Currently this is done with a server side thread, which timely fires an A-synch JS event to notify the web front-end(s) to check if the data has been changed or not.
This mechanism works, but the feeling within the team is that it could be a lot more efficient.
The tool is written in C# / ASP.NET combined with JS and we use the PokeIn library for the aSynch JS/C# Calls.
Any suggestions for improved functionality are welcome! Including radically different approaches still maintaining the JS/C#/ASP.NET usage.
Is this a real question? I would like to add this as a comment but I don't have the enough score.. Anyway, if you need what pokein does for you (object translation among the parties) that is the only option you have. Although there are solutions like websync, signalr.. They don't handle the object translation and has no different approach etc... Better, you benefit from pokein's websocket feature. Both of others needs Windows Server 8 for websocket. Pokein lets you use websocket on any server version or platform..
Sounds like SignalR would help you? This blog post gives a good introduction.
I was trying to solve something similar (reporting real-time updates triggered from an external services communicating with the server) recently and it turned out SignalR is a perfect fit for this situation.
Basically it is a library wrapping long-polling, Web Sockets and few other techniques, using (transparently) whatever is available on server and client.
I only have good experience with it so far.

Categories