Here's a concept you can borrow from Azure's API: http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx
Client
makes request toweb role
for computation.Web role
creates a GUID for this operation.Web role
add requests to Azure Storage Queue & Service Bus, adds GUID to the queued record.Web role
responds back to the client withHTTP 201 Accepted
and GUID asOperationId
in the response body.- Client polls the API endpoint on
web role
to see if the operation with that id has finished. Web role
queries some table storage (db or Azure Table) to see if that operation record is marked as finished.- Meanwhile
worker role
pickes up operation from the queue, processes it and when done, puts the result back to the table storage (or db) so web role can access using OperationId - Meanwhile
client
was polling the API with GetOperationStatus(operationId) call every 1 minute or so. When task is finished and results are Ready, client can callif GetOperationStatus(operationId) == finished { GetOperationResults(operationId) }
through API endpoint onweb role
.
Here, client has never contacted with worker role directly. Because worker roles are supposed to run background operations. And this is done through messaging (queues, service bus etc.)