6
votes

I'm an Azure newbie so forgive me. I'm going to have client apps (web, mobile) sending requests to Azure service bus. How do these clients receive a response from the worker that pulls the message from the queue and processes it? Assuming the following scenario:

  1. A website user wants to get a list of items. They press a button to request the list
  2. The button click sends a request to the Azure queue
  3. The website waits for the response (in ASP.NET on the same web page, same session?)

The same experience would go for mobile apps

1
Confusing question, you wouldn't typically use a SB queue to fill a list, button click runs on the client. All interaction with the SB is (indirectly) done via REST calls, which library you using?Mikee
I would be making a call to Azure in .NET using http client. Was just wondering how to async call an Azure service for data, without having to wait for the response on the UI thread, maybe get a callback, since it would potentially be a long running process. I thought the service bus queue would be a good option.Patrick Goode

1 Answers

10
votes

We have solved this problem using Azure Service Bus as we have two systems that cannot communicate directly with each other via API or other means, but both systems can communicate with Azure Service Bus. Here's how it works:

  1. Client (web site SPA - which we call "Wife") makes a call to its own backend server API.
  2. Server publishes the request to a message queue (queue A).
  3. The other system (which we call "Husband") is subscribed to message queue A, processes the request and publishes a response to another queue (queue B).
  4. The server in step 2 is subscribed to message queue B and has been waiting for a response. It peeks into the queue checking the response is for the same request sent in step 2 and responds to the client in step 1.

Works well. If the Husband (in step 3) is offline, for whatever reason, it processes the message when he wakes back up and publishes the response. The wife client app will timeout waiting for the response - there's a message saying that the data is unavailable at this time, but will be processed as soon as possible. In this case the message is important and we process the dead letter message later.