Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure service bus wait for response

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

like image 626
Patrick Goode Avatar asked Apr 24 '15 13:04

Patrick Goode


1 Answers

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.

like image 90
mkaj Avatar answered Sep 28 '22 02:09

mkaj