How to create a time based event in an MVC5 website?

What is the best design to have time-based events? For example, if you send reminders to users, say 60 days after their last login, or so?

The system is currently built on MVC5, so I was thinking about adding some cronjob to ActionExecuted in the base controller that will run all checks and stuff and do all event based tasks.

Another approach I was thinking was to create a desktop app (console app) and run it all the time and get push notifications from SQL server when new users register, then just save the list and once 60 days send an email email or query the server once a day to get the latest login date for everyone and send an email if any user needs it.

I found this ( http://www.quartz-scheduler.net ) on another SO question: MVC - Run a scheduled task even if no one logs into the application

And I wanted to ask if it would be even better for the system?

Better yet, a newsletter has to be sent to some users every month. How will this be done?

+3


source to share


1 answer


So I ended up using Quartz.NET in the end. I made an MVC app create triggers and jobs, and a separate server runs a console app that executes triggers and jobs.

This can be achieved with Scheduler.Start (); in a console app and not have it in a web app.

In addition, jobs and triggers are stored on SQL Server (Azure SQL) rather than RAM, so both machines can access them.



I also needed to make sure the clock was in sync with the second and changed some of the variables in the config section <quartz>

in Web.config and App.config:

 <add key="quartz.scheduler.instanceId" value="AUTO" />
 <add key="quartz.jobStore.clustered" value="true" />

      

Both systems must operate in a cluster!

+1


source







All Articles