This article will introduce the concept of decoupling between application components using Azure queues. Before going with decoupled architecture with can consider the pros and cons of tightly coupled architecture.
Tightly coupled architecture
If all the components in a single application are tightly connected, then each component will wait for the result. So any single error can throw all the requests away.
In the preceding diagram you can see the traditional web application. There is a front end, that receives the user inputs and forwards the request business layer after some validation. The business layers then ends up querying the database and responses are then propagated back to the front end. What happens when one of the requests times out because of any database failure ? In this case the application throws an error and is presented to the user. The each application component works together to serve the request. The tightly coupling has two main advantages over the less coupled. It is simpler to understand and debug the code. The second advantage is the tight coupling makes the calls between the components faster.
Now you have seen the problem with tightly coupled architecture , so what is the alternative way ? Alternative is the decoupled architecture.
This is just decouple the individual component from on another in an application. However, we will be able to communicate each component and get responses for our requests. Basically queues are the best component to achieve this. The application components named producers that create message and deliver them to a message queue. Other application components called consumers are connected to the queue and get the messages to be processed. Messages placed into the queue are stored until the consumer retrieves them. If the processing component fails, the unprocessed messages are still in the queue and will be processed by a backup or an extra component. Message queue provides an asynchronous communication protocol. Email is the best example for asynchronous communication.
Azure offers Azure storage queues and Azure service bus queues. We can us any of these based on the requirement.
Azure Storage Queues
Azure Service Bus
You will get detailed comparison between Azure Storage Queues and Azure Service Bus from Azure website.