In this article we will be exploring what is Azure Service bus.
You can watch the entire step by step video on Youtube
So what are we going to cover today.
- What is Azure Service Bus?
- Some Terminology
- Application structure Old vs New
- Azure Service Bus types
- Protocols
- Features
In essence Azure Service Bus is a way to send a message from point a to point b. it means that i am going to put the info that i want to send somewhere and the specific service thats needs it will pick it up.
Azure Service bus leverage the idea of async process in the message queue and its very durable.
Once we publish a message to the queue its very hard to loose that data
Traditional application
In a traditional web application, the entire processing will be in the monolith so processing a request can take up to a minute or two and the user will have to wait in the unknown until the request has been processed
In this case all of the requests are being processed by the API server
Pros:
- Easy to host
- Single point of processing
Cons:
- Single point of failure
- Very hard to scale
- bad user experience
- difficult to maintain without down time
Service based application
The application divide the work that needs to be done to different services. Services can run asynchronously and the user will get a faster response while the application does it processing and once the process has been complete the user will get a confirmation.
We can see that the API delegate the processing of the order to different queue and every single one of them is running asynchronously to process the order
Pros
- Scalable
- Easy to maintain without down time
- better user experience
- less error prone
Cons:
- Complicated to host
- multiple services to manage
Azure Service bus:
There is 2 types in Azure Service bus: Queue and Topics
Queue:
- Follow the FIFO model (First in first out)
- The consumer is 1 type of the application
- Point to point model
- We cannot have multiple types of the application as when its consumed by 1 service its lost of ever no other service will be able to pick it up
Topics:
- Topics will have subscriptions
- Once there is a message in the queue every application that is subscribed to the queue will receive a copy of that message
- Publish and subscribe model: deals with contract negotiations and changes because there is more consumers
- Services can have filter to allow only certain types of messages to be sent to them
Azure Service Bus Protocols:
- AMQP is the default one (Advance Messaging Queue Protocol) itβs the one the is used out of the box in the SDK
- HTTP incase there is some firewall rules and access rules this protocol can be used
- JMS (Java Messaging Service) for premium service bus
Features
Dead letterings:
if we publish something into the queue and the processor fails to process the message, it will go back to a separate queue called dead letter queue so we can go back and check what is the issue and incase we fix the issue with the processor we can reinitiate the letters in the queue so we don't loose any information
Message Sessions:
We want to group a list of messages together and process them all in a single instance instead of separate processing
Duplicate Message detection:
In case a message got released multiple times to the queue, the queue is capable to knowing that there is a duplicated and ignores it
Scheduling:
When a message enters the Queue we can give it a date and time on when it needs to be processed by the processors. Only at that time its processed else it will stay in the queue and wait.
Subscription filters:
When we are using the Pub/Sub approach if one of the processors dont want to listen to every incoming message, we can add a filter to the process to accept only certain types of messages
Time To Live (TTL)
Add a deadline to the message so in case the deadline has passed and the message has not been processed it is ignored and not processed
Links to Azure official documentation :
https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview
Thank you for reading
Top comments (0)