I am really puzzled on developing a software which suits my company's requirement. The requirement is as follows,
- I have applications on different platforms(asp.net, wpf, wp7, android, apple app) which access the same database. All the applications need real time data with a acceptable delay of 5 sec. So, whenever a change in the DB occurs, all the applications should
be notified.
I see only one possible and crude way of doing it - polling the DB every 5 sec, which obviously in not the solution.
Use SQL Mail functionality to send email notifications for any DB changes.
OR, on any changes in DB, write/ update a Text/XML file with the update details. And check this file at every 5 sec. Instead of polling DB at every 5 sec., checking Text/XML file will be more efficient.
Sumit Pathak ------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"
I see only one possible and crude way of doing it - polling the DB every 5 sec, which obviously in not the solution.
The problem is there is a slick solution to this problem but it is only feasible for .NET clients and that is by using a Duplex WCF Service. The good news is the duplex service can be used over HTTP and net.tcp but the client must implement the set of Interfaces
required for the callbacks and that will be trouble for non .NET clients and specifically the 'apple app' you listed. There might be hope for Android with
mono but even then I am still not 100% sure. For asp.net, wpf, and wp7 this is
absolutely the recommended way to go vs. brute force polling.
In addition I would not have any of the platforms poll the database directly. You should abstract away any of this functionality into services if possible that are accessed by the client. You could also implement throttling of requests if needed.
You could consider a hybrid solution: 1 for .NET clients and 1 for others. For the .NET clients consider using a duplex service to subscribe to updates where the information will display without polling. As for the non .NET clients, go ahead and poll on
interval (or use a more glamorous approach with
RegisterWaitForSingleObject as opposed to timers) to get the data from a WCF service and I would recommend exposing a RESTful service for these clients. Its the most lightweight and the response can be XML or json for non .NET clients to easily digest.
Lastly, in the future keep an eye on
WebSockets with HTML5 because this will probably be the solution to all
of this in a few years.
Have a look at the following information for more details on duplex WCF services:
gvikas
Member
40 Points
26 Posts
Single DB Server for different types of applications
Mar 13, 2012 06:31 AM|LINK
Hello everyone,
I am really puzzled on developing a software which suits my company's requirement. The requirement is as follows,
- I have applications on different platforms(asp.net, wpf, wp7, android, apple app) which access the same database. All the applications need real time data with a acceptable delay of 5 sec. So, whenever a change in the DB occurs, all the applications should be notified.
I see only one possible and crude way of doing it - polling the DB every 5 sec, which obviously in not the solution.
Is there any other way I could handle this?
Vikas Gowrisetty
Sum8
Contributor
4141 Points
931 Posts
Re: Single DB Server for different types of applications
Mar 13, 2012 07:04 AM|LINK
Use SQL Mail functionality to send email notifications for any DB changes.
OR, on any changes in DB, write/ update a Text/XML file with the update details. And check this file at every 5 sec. Instead of polling DB at every 5 sec., checking Text/XML file will be more efficient.
Sumit Pathak
------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"
gvikas
Member
40 Points
26 Posts
Re: Single DB Server for different types of applications
Mar 13, 2012 09:14 AM|LINK
For that, for example: an android app should access the Text/XML file on a remote computer in the network, which is used as DB Server.
This seems kind off expensive for me !!
Vikas Gowrisetty
Brutus Maxim...
Member
68 Points
15 Posts
Re: Single DB Server for different types of applications
Mar 13, 2012 09:53 AM|LINK
Some kind of broadcast or push based publisher - subscriber pattern might help you. Have a look at the thread http://forums.asp.net/t/1778351.aspx/1?How+to+desing+this+ for a discussion on a similar problem.
If you using SQL Server, query notification services could also help you. Please have a look at http://msdn.microsoft.com/en-us/library/ms130764.aspx Other database servers too might have similar services.
Brutus
atconway
All-Star
16846 Points
2756 Posts
Re: Single DB Server for different types of applications
Mar 15, 2012 04:38 PM|LINK
The problem is there is a slick solution to this problem but it is only feasible for .NET clients and that is by using a Duplex WCF Service. The good news is the duplex service can be used over HTTP and net.tcp but the client must implement the set of Interfaces required for the callbacks and that will be trouble for non .NET clients and specifically the 'apple app' you listed. There might be hope for Android with mono but even then I am still not 100% sure. For asp.net, wpf, and wp7 this is absolutely the recommended way to go vs. brute force polling.
In addition I would not have any of the platforms poll the database directly. You should abstract away any of this functionality into services if possible that are accessed by the client. You could also implement throttling of requests if needed.
You could consider a hybrid solution: 1 for .NET clients and 1 for others. For the .NET clients consider using a duplex service to subscribe to updates where the information will display without polling. As for the non .NET clients, go ahead and poll on interval (or use a more glamorous approach with RegisterWaitForSingleObject as opposed to timers) to get the data from a WCF service and I would recommend exposing a RESTful service for these clients. Its the most lightweight and the response can be XML or json for non .NET clients to easily digest.
Lastly, in the future keep an eye on WebSockets with HTML5 because this will probably be the solution to all of this in a few years.
Have a look at the following information for more details on duplex WCF services:
Duplex Services:
http://msdn.microsoft.com/en-us/library/ms731064.aspx
Building and Accessing Duplex Services:
http://msdn.microsoft.com/en-us/library/cc645026(v=VS.95).aspx
Pushing Data to a Silverlight Client with a WCF Duplex Service (just conceptually showing why polling is not the only option):
http://weblogs.asp.net/dwahlin/archive/2008/06/16/pushing-data-to-a-silverlight-client-with-wcf-duplex-service-part-i.aspx
Hope this helps!
gvikas
Member
40 Points
26 Posts
Re: Single DB Server for different types of applications
Mar 16, 2012 04:40 AM|LINK
Thanks a ton
Vikas Gowrisetty