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.
Related
We have developed a Vehicle Tracking Application in MVC5 using EF6.
The app has a dashboard on which current status of vehicle is displayed i.e. Moving / Stopped/ etc.
To Load current status the dashboard view fires async ajax request(every 20 seconds) to fetch latest data.
Now, rather then making calls from client machine, I want that the client should automatically receive the update as soon as new data is available for its vehicle. It should not poll every 20 seconds.
I've read about SignalR, and tried implementing the Chat program. That's works well. But somehow, I'm unable to figure out "How to use it in my scenario?".
Also, I read about SQLDepedency to detect changes in DB, but again couldn't reach to a solution.
Will be glad, if someone can point me in right direction.
Thanks.
Some time ago I experimented with replacing polling with SignalR too. It was quite straightforward and I used mainly SignalR web as a source of information.
I remember I dealt with some serialization issues but it was more related to the message contract as we used a hierarchy of interfaces and implemented some inheritance in contracts (My question from that time).
Just a suggestion - plan well for scalability - how will your scenario work when you will have to scale out (if applicable) to multiple servers. For my high frequency messaging it was a no-go reason (My question from that time).
maysbe this link can help.
It is SOAP based but also express the fact taht you will have to implement a wbeservice like part on the device.
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.
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.
My assignment is to create an App for a Mobile Device (Like iphone/android/BB/etc..), the purpose of this app is to tell the users there is something new on the website and then show an list (inside the App) showing the latest updates.
The Company insisted I use ASP.NET/C#/Visual Studio and use the SOAP protocol.
I've started working with C# and then using the so called WCF.
I've already got some stuff working. (Like "consuming" the WCF from an Android App and getting data sent back).
My Question is what will be the best "Architecture" to work with for the Mobile App Development. I was thinking about have only 1 WCF and then call a general function like Do() (Or some other name :)) and then adding a soap header where u can define what u want the service todo. Like getting a record from the database, or ping , er something else, whatever the company may need in the future :)
How this would work:
The Client (Mobile App) would make a call to the WCF, and in the soap header is states, lets say, it wants to register the Phone with the Device ID. The WCF will receive the Soap Requests, extract the header and use some sort of switch to decide what it needs todo. Once it knows that to do the WCF will then, for example, access some local Classes to insert/retrieve Database data or do something else and when its done it will simply return what is needed. (Like an OK sign or data or something else.. :)).
Is this a right approach, cause how I am looking at this, it makes it very easy for changes on the back end without updating the App.
Sorry if this a retarded question, but I am new to WCF and Mobile App Development, and i'am trying to deliver a great product at the end of my internship. I was just wondering what sort of "Architecture" you guys suggest I would use for this sort of assignment.
EDIT
I already told them SOAP is too heavy for mobile development and shown them some graphs. But they insisted to use techniques they already know.
After doing some research I indeed think the contract based approach is the better way to go. But can you maybe answer a few questions regarding it?
-Can I have like one WCF file that gets "consumed" which holds all the different operations?
-Can I authenticate the client (With using Soap headers Required) at the beginning of the WCF and after that call the desired operation?
SOAP is generally regarded as a little too heavy for mobile development. Since users may incur data charges and generally have lower bandwidth, it would be preferable to take a REST/JSON approach. You can still use WCF to do this at the server.
You can use a generic operation (MessageAction="*") but you will then need to handle the serialisation/deserialistion of messages yourself. However, unless you have a pressing reason to do this I would suggest properly structured operations are the better way to go. They are much more maintainable. You can still make implementation changes at the server without affecting the client, as long as the message contract does not alter. The reality is that if you want to change the message or operation contracts you will have to make changes to the clients anyway. After considering this, the 'contract' based approach only has upsides and no real downsides.
I am wondering, very generally, about the feasibility of a WF solution in an application, where the business owners want extensive reporting capabilities on application state and data.
The main issue that I see is that WF tends to hide data, such as a recipient list, that is serialized inside the workflow instances, so it can't be reported on, in a way I'm aware of.
On the other hand, if the instance data is written out to an external resource such as a sql table, then haven't you just given up your ability to change that part of the workflow at will (taking away a major selling point for WF)?
In WF for .Net 3.5, I understand the SqlTrackingService can provide raw data about Workflow instance events, Activity events, and User events. But, I wonder about the scalability of logging a lot of instance data, in the activities, to User events. Also the schema I see that the SqlTrackingService uses looks like it would be hard to maintain a reporting solution on, especially if there are updates to the workflow over time. Am I wrong here?
So, has anyone out there successfully used WF when reporting was a major concern? If so, I'd like to hear about how it was done, if WF was isolated to only certain parts of the app (having data not applicable for reporting), and so on...
Perhaps, this is just a question about reporting in a BPM solution in general, as well...
EDIT:
I've accepted Maurice's answer because he took the time to answer it, but I'm still interested in any other opinions on this!
Using the SqlTrackingService in combination with tracking profiles is quite performant, specially when you enable transactional logging. Basically you want to use the tracking profile to only track events you are really interested in. You can also tell it to extract and log specific pieces of user data.
The main way to retrieve the data is not through SQL, although that is possible and for some queries like give all workflows executing a specific activity, but the SqlTrackingQuery class. This will also deserialize the additional user data.