0
votes

I have a worker role(WR-1) to put messages in Azure Queue. WR-1 is scheduled using Quartz.NET.
I have another worker role(WR-2) that processes the messages on Azure Queue.
I would like to trigger the WR-2 from WR-1 once the queuing activity is finished.
I couldn't find any material on how to instantiate a worker role from another worker role. Is it possible? How can it be done?

1

1 Answers

2
votes

If your worker roles are different applications, you could make use of Service Management API to create a new deployment for WR-2 from WR-1. What you would do is put the package and configuration files of WR-2 in blob storage and when WR-1 has done putting all the messages in the queue, you create a new deployment of WR-2. To create a deployment programmatically using Service Management API, please see here: http://msdn.microsoft.com/en-us/library/windowsazure/ee460813.aspx. However you would need to ensure that once WR-2 has done all the data, it is destroyed by WR-1 so that you don't keep on incurring charges.

Other possibility is to run your worker role instances to run in Master/Slave configuration. Let's say there are 2 instances of your worker role running. One of the instance would be a Master instance which will put the data in the queue and once data is put in the queue, it will write a message in some other queue signalling Slave that it is done writing the data. Slaves will constantly poll this other queue and once they find that Master has finished putting the data, they can start fetching the data from the queue containing actual data and process them. To decide which instance will be Master and which ones will be Slave you could make use of Lease Blob functionality. The instance which is able to acquire lease on the blob will be the Master while other instances be Slave.