Just as with queues, subscribers can go offline, and then “catch up” on messages when they come back online. This approach allows applications to follow the open/closed principle, since they become open to future changes while remaining closed to additional modification. Messages are published to the bus, and any application that has subscribed to that kind of message will receive it. Unlike queues, where the sending application explicitly adds messages to every queue, a message bus uses a publish/subscribe model. Application C can be configured to listen to the message bus and take action based on these updates as well, without requiring any update to application A. Later, application C is written that can also benefit from these updates. Thus, an application A could be written to communicate status updates to application B via a message bus. There may be no guarantee of first-in-first-out ordering, and subscribers to the bus can come and go without the knowledge of message senders. Message BusĪ message bus or service bus provides a way for one (or more) application to communicate messages to one or more other applications. This blurs the line between queues and buses, especially as it pertains to the 1:1 correspondence between queues and destination applications. During this time, the message can still be read by other applications. Messages become “invisible” to applications that have read them for some period of time before actually being removed. Some modern message queue implementations (such as Amazon SQS) can support having a single message be read by multiple endpoints. Thus, there is usually a 1:1 correspondence between message queues and dependent applications (endpoints). Since messages are typically discarded when read, it is (was – see below) unusual to share a queue among multiple different dependent applications (though a queue might be shared by multiple instances of a single application running in parallel). Thus, for rapidly evolving (or complex and long-lived) applications or systems, this approach tends to violate the Open/Closed Principle. Writing to new queues typically requires updating the originating application. Since the typical scenario involves a separate message queue per dependent system, adding new systems means adding more queues. This helps break dependencies between dependent systems and can provide greater scalability and fault tolerance to applications. Each message queue is persistent, so if an application restarts, it will begin pulling from its queue once it is back online. Neither B nor C need to be available in order for A to send updates. A would write separate messages to each queue, and each dependent application would read from its own queue (the message being removed upon being dequeued). In many architectural scenarios, if application A needs to send updates or commands to applications B and C, then separate message queues can be set up for B and C. Message QueueĪ message queue receives messages from an application and makes them available to one or more other applications in a first-in-first-out (FIFO) manner. A common question I encounter is, “what is the difference between a message bus (or service bus) and a message queue?” There has been some blurring of the lines between these two concepts, as some products now support features that previously belonged only to one or the other category (for instance Azure Service Bus supports both approaches).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |