How do I automatically start an Azure Queue?

I want to create an Azure app with two worker roles and NO web roles. When the worker roles are started first, I want ONLY ONE of the roles to do the following at a time:

  • Download and analyze the master file and then run several "child" tasks based on the contents of the main file
  • Run one main file by loading the "child" task to start the next day.

Each of the "child" tasks will be performed by both workers until the task queue is exhausted. Think about everything about "priming the pump"

It's very easy if I add the first "main" task manually to the queue by calling the web role, but it seems very difficult to do in autorun mode.

Any help in this regard would be greatly appreciated!

Thank.....

+2


source to share


2 answers


One possibility: instead of invoking the web role, just load the queue directly. (It looks like this is an application that you want to automatically deploy to do some work and then close again ... if you automate this it should be trivial to automate the queue loading as well.)

A (arguably) better option: use some kind of locking mechanism to ensure that only one instance of the work object does initialization. One way to do this is to try and create a queue (or blob or entity in a table). If it already exists, then another instance handles the initialization. If creation is successful, then this is the job of this instance.



Note that it is always better to use a lease than a lock when the initializing instance fails. Consider using a timeout (for example, storing the timestamp in table storage or blob metadata or queue name ...).

+2


source


We ended up with the same problem, so we introduced an O / C mapper (object to cloud). Basically, you want to introduce two types of cloud services:

  • QueueService that consumes messages whenever they are available.
  • ScheduledService that starts scheduled operations.


Then, as suggested by others, in the cloud, you really prefer to use leases instead of locks so that your cloud application isn't permanently stuck due to temporary hardware (or infrastructure).

+2


source







All Articles