I am building a website that will fetch data from xml feeds. I am building it as an MVC AP.NET application. I will need the application to get data from the xml files located on the provider's server every 2 minutes for example. These data will then be stored. My problem is that I want these procedure to be done without interruption from the moment the website will be uploaded on server. I was thinking of using a timer in the main method(?) to get the data every 2 minutes. But I have searched other topics here and I found out that using AppFabric would be the solution. The problem is that I am an absolute beginner and I find it difficult to use it... Is there an other more simple way to achieve this continuous update of data from the xml file?
I would recommend you use Quartz to handle the scheduling instead of using the built-in timer. I have used Quartz in my last two projects and I have been very impressed. It can handle about any schedule you can think of.
http://www.quartz-scheduler.net/documentation/quartz-2.x/quick-start.html
Example Job Creation:
using Quartz;
using Quartz.Impl;
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
scheduler.Start();
IJobDetail integrationJob = JobBuilder.Create<IntegrationJob>().Build();
ITrigger integrationTrigger = TriggerBuilder.Create()
.StartNow()
.WithSimpleSchedule(x => x.WithIntervalInSeconds(300).RepeatForever()).Build();
scheduler.ScheduleJob(integrationJob, integrationTrigger);
public class IntegrationJob : Ijob
{
public void Execute(IJobExecutionContext context)
{
//Write code for job
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With