Web role keeps connection to send a response when the result is available RRS feed

  • General discussion

  • Here are steps:

    1. Client sends REST POST request to a web role (web role has multiple instances)

    2. Web role does not respond immediately and keeps connection to send the response later when the result is available

    3. Web role pushes a message to Send Queue (Service Bus Topic)

    4. A Worker role gets the message from the Send Queue, processes it and sends to Receive Queue.

    5. The Web role now, somehow, notified that appropriate message is available in the Receive Queue and finally sends a response to the POST request.

    How should I implement 2 and 5?

    I was thinking about creating paused thread on step 2 and resuming it on step 5. Will it be acceptable?

    Thursday, May 9, 2013 1:35 PM

All replies

  • 2 will be problematic because the Azure Fabric will terminate connects that sit idle for more than 60 seconds (if my memory serves). Additionally, holding open idle connections can cause scale issues as there is a limit on the number of simultaneous connections to a cloud service.

    I would instead look at alternative methods such registering callback endpoints, push notifications, or having the client poll for results. A common approach for this is implementing the call and poll via client side javascript. This has the added value of ensuring that the entire transaction from client to server and back is asynchronous.

    Thursday, May 9, 2013 2:21 PM
  • Hi,

    not sure how are you are implementing it (i mean what technology), if the intent is to use microsoft technology stack I think this can be simplified using SignalR



    Please Mark it as answered if it helped

    Vishal Narayan Saxena http://twitter.com/vishalsaxena

    Friday, May 10, 2013 5:54 PM
  • It is multiplatform approach. Considered to use SignalR but it does not feet for it.
    Friday, May 10, 2013 7:24 PM
  • Comet for Php?

    Vishal Narayan Saxena http://twitter.com/vishalsaxena

    Saturday, May 11, 2013 2:10 AM
  • Hi Vishal,

    I need to keep client as thin as possible so it just sends simple POST and receive result. I would like to avoid long polling third parties.


    Saturday, May 11, 2013 8:32 AM
  • HTTP by nature will not keep connection unless you do something special, and it will be synchronous too.

    I recommend you look for options where you can do it outside PHP and use the results in PHP by having some kinda connection between PHP and reciever


    UI -> PHP -> Sender/Reciever -> Poll results

    And return path be same, advantage is that you dont need sender / reciever in PHP 


    Please mark as answered if it helped

    Vishal Narayan Saxena http://twitter.com/vishalsaxena

    Saturday, May 11, 2013 5:04 PM