My ASP.NET app can run on multiple virtual servers (e.g. in Azure I can scale on demand). I'm not sure where I will host my app, whether it will be Azure or some other hosting service, but I faced with the following problem:
I need to run jobs on some schedule: get exchange rates and they should be available for all server instances, check database and send emails, manage app cache or logs or do some other jobs in background.
What I don't understand well is how to build/architecture the system so that those jobs are executed only once (I don't want to pull exchange rates on every app instance or send emails more than once). So simple use cases of some Quartz.NET or QueueBackgroundWorkItem don't suit me.
I know that Azure WebJobs is capable of doing such things, but I do want the solution that doesn't not depend on hosting service like Azure, because maybe tomorrow I will want to move to another hosting service.
Thanks.
Have you taken a look at NServiceBus (and the Particular Service Platform)? It can be used as a deployment-agnostic API for asynchronous message processing and deployed both to Azure as well as on your own servers.
When run on Azure, it leverages Azure Service Bus and when on your own server farm, you can choose MSMQ, RabbitMQ, and even SQL tables as your transport.
NServiceBus leverages dependency injection quite heavily so testing your solution is very easy.
Hope that helps.