Azure provides various messaging solutions such as Azure Storage Queues, Services Bus, Event Grid and Event Hub. Which one should you use and why? This post uses real business examples to illustrate the difference between Azure Service Bus and Azure Event Grid to assist in your architecture decision-making process.
The previous post looked at the benefits of changing push to pull with a publisher-subscriber pattern using Azure Service Bus.
Figure 1 below, taken from the previous post, illustrates how an online booking tool (OBT) publishes booking messages to a topic where travel providers can subscribe and pull bookings from a queue.
But what happens if the travel provider doesn’t want to pull messages from a queue or has no capacity or appetite to develop a worker service? What if the only option is to call the travel provider’s REST API?
Let’s consider pushing the bookings to the travel provider’s REST API. Wait a minute! The previous post outlined various issues around availability, scalability, and reliability when pushing bookings to the travel provider’s API. That’s why the architecture was changed to a publish-subscribe pattern using an Azure Service Bus.
As shown in Figure 2 below, instead of pushing bookings from the OBT directly to multiple Travel Provider APIs resulting in high coupling and fragility, use Azure Event Grid to notify a serverless function when a booking is available to transform the event in an API call to a travel provider’s endpoint.
Let’s review the benefits of Azure Event Grid:
It depends on the use case and business requirements.
Azure Service Bus works well when services can pull requests from a queue or if you need features such as guaranteed ordering, transactions, duplicate detection or long-running operations with renewable locks.
Azure Event Hub works well when requests are pushed to a service such as an API and events are processed within 24 hours and endpoints do not take longer than 30 seconds to respond.
Would you like to find out more or discuss your use case? Get in contact with our team today.
Would you be interested in learning more about messaging and queuing systems? Have a read of these other blog posts: