Azure - Background tasks

Topics: General
Sep 12, 2012 at 4:46 PM

We have a requirement to import content from third parties into Orchard. Our initial idea being that we could use a background task. However, our implementation is hosted on multiple Azure instances. Would this mean that the background task would get executed on each of the instances?

Sep 12, 2012 at 4:54 PM

There is a task lease feature in Orchard that exists for exactly that purpose.

Sep 12, 2012 at 5:08 PM

Excellent. Do you have an example implementation of this? Looking around documentation seems to be sparse

Sep 12, 2012 at 5:29 PM

Your best bet is to find existing usage of it.

Sep 12, 2012 at 7:55 PM

Beware though that since Task Lease uses DB to store tasks it will only prevent multiple instances doing the same task if subsequest tasks are only started after the first one has finished (and committed its transaction to the DB). If you want to prevent simultaneous execution, take a look at Helpful Libraries (Tasks Libraries/LockingCachaManager and LockFileManager).

Sep 13, 2012 at 9:56 AM

colleague of Andy's here; we looked at the code and pretty much figured out how to use it as we couldn't find any existing usage anywhere - but as Piedone said it certainly has some pitfalls and scope to fail. Will take a good look at the helpful libraries sounds like it might be similar to some ideas we floated about last night about using distributed cache to prevent it etc.