I have a windows service that listens for Azure Service Bus Queue Messages in order to distribute processing from my WebApi application. I additionally need to handle recurring tasks (nightly/weekly), which I thought might be best handled using the same system.
For example, assume I have a queue for "CleanupDb" to delete stale DB nodes every day at midnight:
var client = QueueClient.Create("CleanupDb");
var options = /* ... */
client.OnMessage((message) => {
client.Send(new BrokeredMessage() {
ScheduledEnqueueTimeUtc = DateTime.Today.AddDays(1)
});
// do DB Cleanup
}, options)
In theory this should work, but I feel like I missing a more obvious way of handling this. Is there a better way?