delete_this_account
delete_this_account

Reputation: 2446

Azure Worker Role communication

I have a starter worker. It does some initializations. I want other workers to wait this starter worker. The only way in my mind is to put messages in a queue. Workers will poll the queue. They will start after reading the messages. Is there a better way to synchronize?

Upvotes: 1

Views: 472

Answers (1)

David Makogon
David Makogon

Reputation: 71055

The problem with queue-polling: Once one worker sees the "I'm ready" queue message, what happens with the other workers? If the reader deletes the queue message (as it should), the others never see it. If the reader doesn't delete it, then you have that message there for the rest of time (and next time you boot up, the message is still there).

What if you hosted a very simple wcf service on the booting-up worker role instance with an AreYouRunning() method returning true/false? If the instance is still in OnStart(), you shouldn't be able to connect to the service. Once you do connect, you just check the return value. You'd just need your other roles to set up some type of polling mechanism in their OnStart() or Run() to do the periodic polling.

There are probably other ways to do this, such as having a row in an Azure Table. You'd still have to ensure you can clear the "running" status from that table prior to the other roles starting up, so the wcf service idea might serve your needs better.

Upvotes: 2

Related Questions