As we become more distributed in our everyday lives, we must change our approach and view of how we build software. Distributed environments call for distributed software solutions. According to Wikipedia, a distributed system is a software system in which components located on networked computers communicate and coordinate their actions by passing messages. The most important part of a distributed system is the ability to pass a unified set of messages. Windows Azure Service Bus allows developers to take advantage of a highly responsive and scalable message communication infrastructure through the use of their Relayed Messaging or Brokered Messaging solutions.
Relay Messaging provides the most basic messaging requirements for a distributed software solution. This includes the following:
- Traditional one-way Messaging
- Request/Response Messaging
- Peer to Peer Messaging
- Event Distribution Messaging
These capabilities allow developers to easily expose a secured service that resides on a private network to external clients without the need of making changes to your Firewall or corporate network infrastructure.
Relay Messaging does not come without limitations. One of the greatest disadvantages of relay messaging is that it requires both the Producer (sender) and Consumer (receiver) to be online. If the receiver is down and unable to respond to a message, the sender will receive an exception and the message will not be able to process. Relay messaging not only creates a dependency on the receiver due to its remoting nature, this behavior also makes all responses subject to network latency. Relay Messaging is not suitable for HTTP-style communication therefore not recommended for occasionally connected clients.
Unlike Relay Messaging, Brokered Messaging allows asynchronous decoupled communication between the Producer and Consumer. The main components of the brokered messaging infrastructure that allows for asynchronous messaging are Queues, Topics, and Subscriptions.
Service bus queues provides the standard queuing theory of FIFO (First In First Out). Queues bring a durable and scalable messaging solution that creates a system that is resilient to failures. When messages are added to the queue, they remain there until some single agent has processed the message. Queues allow overloaded Consumers to be scaled out and continue to process at their own pace.
Topics and Subscriptions
In contrast to queues, Topics and Subscriptions permit one-to-many communication which enables support for the publish/subscribe pattern. This mechanism of messaging also allows Consumers to choose to receive discrete messages that they are interested in.
Common Use Cases
When should you consider using Windows Azure Service Bus? What problems could Service Bus solve? There are countless scenarios where you may find benefits in your application having the ability to communicate with other application or processes. A few example may include an inventory transfer system or a factory monitoring system.
In an effort to offer exceptional customer service, most retailers will allow their customers to have merchandise transferred to a store that is more conveniently located to their customers. Therefore, the store that has the merchandise must communicate to the store that will be receiving the product of this transaction. This includes information such as logistical information, customer information, and inventory information. To solve this problem using Windows Azure Service Bus, the retailer would setup relay messaging service for all retail locations that could receive a message describing the inventory transfer transaction. When the receiving store gets this notification they will use this information to allow the store to track the item and update their inventory.
Windows Azure Service Bus could also be used to enable factory monitoring. Typically machines within a factory are constantly monitored to insure system health and safety. Accurate monitoring of these systems is a cost saver in the manufacturing industry because it allows factory workers to take a more proactive response to potential problems. By taking advantage of Brokered Messaging, the factory robots and machines can broadcast various KPI (Key Performance Indicator) data to the server to allow subscribed agents such as a monitoring software to respond to the broadcasted messages.
In summary, Windows Azure Service Bus offers a highly responsive and scalable solution for distributed systems. For basic request/response or one-way messaging such as transferring inventory within a group of retail stores, Relay Messaging will meet most system requirements. If your requirements call for a more flexible system that will support asynchrony and multiple message consumers, it is better to take advantage of the Queues and Topics that are made available in Brokered Messaging.