views:

52

answers:

2

I am building a web application in asp.net MVC and am thinking how I can get certain conditional tests to happen regularly.

Currently I am planning on having a page such as /utility/runJobs that will have a function in it that will test the whole site for dates meeting certain conditions etc..

I would then trigger this page from a service or other trigger service.

I would probably run this every min incase new notifications had to be sent out, or a Log item had to be written, or a status updated.

Can anyone suggest a better way of doing this.

EDIT___________

Imagine how the notification emails for ebay are sent?

I guess that the badges on stack over flow are tested when a user comes to the site, and only for that user.

+1  A: 

If you are planning to write a Service to trigger your Jobs then I would suggest that you execute your jobs in your Service.

With MVC you have hopefully already separated you logic from you Views so it should be easy to implement the service.

Arthur
That sounds good, thanks. But is there a better way to do this than just triggering a function every min, some kind of event binding or something?
optician
Jobs that are bound to a User Action are not "realy" jobs. Just execute them. If the took too long, enqueue them. A lookup in a job database table does not cost very much. Same for recurring jobs. A lookup "what's todo next" is not expensive (with a good database design)
Arthur
A: 

First big protip: what you are looking to do shouldn't require a single web page. Or, what you really need to think about here is services, command line apps and queuing, not having a page that gets hit once a minute.

Wyatt Barnett