I want to execute a job scheduler methods in my windows azure application. So in my application i am using 2 instance of the same application. So If i create a scheduler means both the instance can execute same code. Is it possible to avoid such execution?
Or is it possible check other instace before executing the code? For the implementation i am using c#.Net.
Usually Scheduled jobs are executed with worker role/s. The logic can be that the input for the jobs can be queued through Azure queues and the jobs will be picked by one or more Worker roles
(In which the schedulers are running).
the lock statement is limited to an application on a single instance! There are some other synchronization mechanism available for system wide use, however non of them enables syncronization across instances!
For that you'd need some other way to synchronize functionality, where using a lease on CloudBlob such as used in the sample above may be one of them, there could be others too.
I've got the exact same problem, so I know what you're saying. I have two identical instances that both dequeue messages and do the requested work - effectively splitting my workload across the two instances. However, the problem is that I still need something
put push the messages into the queue on a scheduled basis. I've toyed with the idea that Brent offered up, but anticipate that it's a bunch more work than I was willing too take on.
My current solution is to have an auxiliarly worker role running in it's own instance that does the scheduling and enqueuing. It's not necessarily cost effective, but it works.