Broker Pattern
   HOME

TheInfoList



OR:

The broker pattern is an
architectural pattern An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. The architectural patterns address various issues in software engineering, such as computer hardware perform ...
that can be used to structure
distributed software A distributed system is a system whose components are located on different networked computers, which communicate and coordinate their actions by passing messages to one another from any system. Distributed computing is a field of computer sci ...
systems with decoupled components that interact by
remote procedure call In distributed computing, a remote procedure call (RPC) is when a computer program causes a procedure (subroutine) to execute in a different address space (commonly on another computer on a shared network), which is coded as if it were a normal (l ...
s. A broker component is responsible for coordinating communication, such as forwarding requests, as well as transmitting results and exceptions.


Definition

The broker pattern is an architecture pattern that involves the use of an intermediary software entity, called a "broker", to facilitate communication between two or more software components. The broker acts as a "middleman" between the components, allowing them to communicate without being aware of each other's existence. In the broker pattern, the broker is responsible for receiving messages from one component and forwarding them to the appropriate recipient. The components that communicate through the broker are known as servers or clients. The broker may also perform additional tasks, such as filtering, modifying messages, ensuring a quality of service (QoS) (e.g. 0 for "at most once"), security, or providing additional services to the software components. The broker pattern allows the components to remain decoupled and focused on their own responsibilities, while still being able to communicate and collaborate with other components in the system. It can also be used to reduce the number of dependencies between components, making the system more flexible and easier to maintain.


Terminology

Broker * Maintain a routing table of registered software components. * Maintain a filter table to reroute the transiting messages to the right software components. * May assure additional functionalities such as
information security Information security, sometimes shortened to InfoSec, is the practice of protecting information by mitigating information risks. It is part of information risk management. It typically involves preventing or reducing the probability of unauthorize ...
and quality of service. Server * Software components responsible for sending a message out. * It is also referred to as a ''publisher''. Client * Software components that subscribed and await a specific message. * It can also be referred to as ''a consumer'' or ''subscriber.''


Advantages

Source: * Dynamic changes, additions, deletions, and relocations of components possible. * One source of communication with the broker, which defines the interface. * Components do not need to know each other.


Disadvantages

* One central component that needs to be robust and efficiently written. * No data consistency of transmitted messages.


Real-life implementation of the pattern

* Message broker *
RabbitMQ RabbitMQ is an open-source message-broker software (sometimes called message-oriented middleware) that originally implemented the Advanced Message Queuing Protocol (AMQP) and has since been extended with a plug-in architecture to support Str ...
*
MQTT MQTT (originally an initialism of MQ Telemetry Transport) is a lightweight, publish-subscribe, machine to machine network protocol for Message queue/Message queuing service. It is designed for connections with remote locations that have devices ...


Confusions around the pattern

The broker pattern and publish–subscribe pattern have some similarities and are sometimes confused. Nevertheless, when it comes to the representation, there are some core differences: * The ''Broker architectural pattern'' is represented by a ''Many'' to ''One'' to ''Many'' diagram. * The ''Publish-subscribe architectural pattern'' is represented by a ''Many'' to ''Many'' diagram. Here, the messaging functionalities are ''hidden'' as a
Cross-cutting concern In aspect-oriented software development, cross-cutting concerns are aspects of a program that affect several modules, without the possibility of being encapsulated in any of them. These concerns often cannot be cleanly decomposed from the rest o ...
.


References

Software design patterns {{compu-prog-stub