In our application, we need to build something similar to SharePoint timer service. This service needs to be installed on all web servers in a farm. A job can be scheduled to be run immidiately, daily, weekly or monthly on any or all web servers of the farm. Jobs configuration and schedule is stored in database (MS SQL 2008).
How SharePoint timer service executes these jobs exactly at the scheduled times?
Does it get notified by SQL Server? (Notification services not available in SQl Express)
Does it poll SQL Server after specific intervals to find if any job needs execution? (Does not guarantee precision.)
Or what?
I would recommend that you use an existing framework
http://quartznet.sourceforge.net/
https://stackoverflow.com/questions/tagged/quartz.net
Related
If the C# server is offline then Windows Service will storage the data in SQLite and when the server is back online it will process the data. I can use a trimmer to check the server is online in every 5-10 sec. I wonder is there any better approach to deal with this kind of scenario?
The right solution for scheduling simple processes is the Windows Task Scheduler.
If you're writing a Windows Service that runs a timer, you should re-evaluate your solution. ..
–Jon Galloway, ASP.NET MVC community program manager, author, part time superhero
//TODONT: Use a Windows Service just to run a scheduled process
Currently working on a .NET solution for an application server. I'm using .NET 4.0 running on Windows Server 2008 R2 with IIS 7.5.
My requirements are:
The application server can run multiple Console applications at once on a schedule - Quartz.net looks like a really good solution to this problem - and is working well for me so far
The application server will also host a web application that will report on jobs (what time they ran, what they did, how long they took etc)
I would like to be able to restart the "service" that is running my jobs and trigger ad hoc jobs from the web interface.
The Service that is running my jobs needs to run all the time
Once this is live I will not have direct access to the machine to restart a Windows Service, but i could potentially setup IIS to be able to do this for me.
WCF Services looks quite promising to me - but I'm not sure where to host it. My current project uses a WCF Service to run console applications using the Quartz.net plugin. Configuration for what to run and when to run it is stored in an oracle database and my WCF service connets directly to the database to retrieve this information (not sure if that is the intended use of WCF).
If I host the WCF Service in IIS / WAS then running the console applications might be a security concern from what I've read. I can keep the WCF service running all the time using appFabric at least. Alternatively I could host it in a Windows Service and allow my web app to consume the WCF service to report on the jobs. I'm concerned about using a Windows Service though as I wont have direct maintenance access to this machine and if it breaks I'm in trouble. I would really like to be able to do the maintenance from a web application. A windows service also feel a little unnecessary given it can be hosted from IIS.
So my question is - is a WCF Service the right approach to this problem or can anyone think of a better approach?
If a WCF service is a good approach - where should I host it so that I can perform maintenance via a web interface given I will not have direct access to the machine itself?
Should the WCF service be the one to start and schedule the jobs?
I think you're overengineering it, possibly.
The Problem: You have a web site which needs to start up jobs on an ad-hoc basis. Other jobs will be run to a fixed schedule. The web site will report on all/any of these jobs.
For running the scheduled jobs, a Windows Service using Quartz is indeed an ideal solution for the fixed schedule part. However, to report on those jobs the data must be collected by the Service and made available. A service can be set up to restart on fail, so you can guarantee that it will always be running (barring a minute or two when it's restarting if it fails - and why should it?. However, any history will be lost unless the Service stores it somewhere it can be retrieve it after a restart.
The simpler solution to the web site getting the history is for the Service to write its data to a database. Then it doesn't worry about a restart: all the history has already been saved, and the data can be read by the web site at any time.
Similarly, if the web site talks directly to the Service (as a WCF Service or otherwise) then what happens if the service is not currently running? The request gets fails until the restart is completed. Frustrating for the user. Alternatively, the web site puts the request into the database. The service monitors the database for requests, and starts jobs appropriately when it sees a new request. If a request is written while the service is not running, when it restarts it will see the request(s) in the DB and execute them.
So I think using a WCF service is overkill, and actually introduces some problems: persistence of history, and what to do about requests made while the service is down. These problems don't arise if you go the way I've described.
Cheers -
So here is my requirement,
I have a service provider that generates a files with data in a proprietary format on a text file. I have to download the file, parse it, then process it for specific records, and then update the database accordingly. The process needs to run multiple times on specific days (mostly Mondays & Fridays).
I am using Windows Azure platform. My website is hosted on azure & using SQL Server as my database. Using C# to create the database updater app.
What is the best approach to schedule a database updater job? Do I even need the updater application to be written on there is some better way to achieve the above.
Thanks
Based on the information you've provided I'd start by exploring Web Jobs (http://www.hanselman.com/blog/IntroducingWindowsAzureWebJobs.aspx).
Web Jobs allow you to create a schedule jobs that will run for you at intervals or continually.
I'm currently in the process of developing a front facing ASP application for a client which is wired up to the ReportService2010.asmx web service. We are using SQL Server 2008 R2.
I have figured out how to fetch all schedules and create them on our end through the interface, but I can't figure out how to then create a subscription that is then connected to that schedule so that it runs at the time.
Can someone help me please?
In the end I found that unless some custom assemblies are added to the report server, subscriptions do not connect to schedules and are two different things.
I am building an ASP.Net website, I have a db table which I want to reset a column in it for all rows. column type: byte
I want to do this every day at midnight, in an automatically way. I know I can set a job in SQL Server Management Studio but I want to do this in a programmatic way and my website will be the trigger for it.
I'm using C#.Net 2008 and MS SQL Server 2005
i.e. (Pseudo code)
if(new_day)// can we be accurate that time here will be around 12:00:05 at maximum?
// call sql stored procedure to reset that column
You could make a simple Windows service in C# that would run in the background but considering all you want to do is make database updates, it's best to keep it in the DB....I'd suggest going with the scheduled job in SQL
Your website only executes when a page is requested making it unable to act as a service that executes a task at regular intervals. The best solution is to use SQL Server directly to schedule the task, create your own service or execute an application at regular intervals using Windows task scheduler.
However, if you for are in hosted environment you may not be able to do any of this. In that case you can use the cache to simulate a service. Omar Al Zabir has an article on CodeProject that explains how you can do that: Simulate a Windows Service using ASP.NET to run scheduled jobs.
If you really want to: create a Scheduled Task that calls your website every day at midnight. The website itself cannot trigger itself, but a task can do this.
But really: just set up a SQL job.
SQL Agent job, scheduled to run at the specified time.