mercredi 21 septembre 2016

Design Patterns for C# Windows Services that send date driven messages

For simplicity, I'm going to use the scenario of sending birthday emails to a customer base of ~1,000,000 customers (stored in a DB), as my own scenario I'm trying to solve is similar.

Typically, the solution I would design would be to create a Windows Service, scheduled using Quartz.net, which would poll the entire table of customers (albeit indexed) looking for birthdays which match today's date (or whenever the Service runs). The Service would loop round the list of customers and send the email etc. This would be scheduled to run, say, once a day.

I was wondering if this is the normal approach to solving this problem, or is there a better way / different pattern? Polling the database to me feels... a bit smelly..

I'm thinking that since we know the customers birthday when they sign up, (for example, their birthday could be in a weeks' time), should I at the point of signing up, pro-actively set up the schedule to run then?

One thing I'm trying to avoid is polling the database when we know there aren't any birthdays on that day for example (ok, out of 1,000,000 customers you'd expect that there were a few!... but let's pretend there aren't any for a whole month..) - what solution would avoid that problem?

Thanks

Aucun commentaire:

Enregistrer un commentaire