Search code examples
asp.net-mvcrazorpollingazure-queues

Poll an azure queue and update view when data arrives in queue Asp.net Mvc4


I have a scenario where a request is sent to a service via my client now the response comes inside a message queue in azure, How can I poll the queue at client end and update the view when the response comes say I have to update a label when data is recieved in the queue.


Solution

  • Azure has two types of queues - Azure Queue and Service Bus Queue. Although in theory you can access them from client side (I assume JavaScript) because CORS has been introduced some time ago (Not sure about CORS support for ServiceBusQueue), this might not be the best option.

    Problems you might face:

    • Lot's of clients trying to process messages (locking and releasing), Azure Queue does not support sessions so you would have to either create queue per client or use Service Bus Queue (as I said earlier not sure about CORS) with sessions
    • What should happen when your client is not online anymore? Does the message stays in the queue? Till when? Expiration?

    Different approach

    You can do message processing on the server and only notify user about the change using SinglalR. This gives you much better flexibility (one message can trigger notification for many users etc).

    SignalR Scaleout with Azure Service Bus

    Using SignalR with Azure Table Storage - What architecture?