【Architectural Pattern】Broker Pattern

Posted by 西维蜀黍 on 2019-01-06, Last Modified on 2024-05-02

Broker Pattern

A broker may be implemented in either a Pub/sub model or Point-to-point (P2P) model.

  • The publish-and-subscribe (pub/sub) model is intended for a one-to-many broadcast(Multicast) of information
  • The point-to-point (P2P) model is intended for a one-to-one communication (Unicast) between two specific applications.

Pub/sub model

In the pub/sub model, multiple consumers may register an interest with, or subscribe to, a topic. A producer sends a message on that channel by publishing on that topic. Each subscriber receives a copy of that message.

Point-to-point (P2P) model

In the point-to-point model, only one consumer may receive a message that is sent to a queue.

A point-to-point queue may have multiple consumers listening for the purposes of load-balancing or “hot backup”; however, only one receiver may consume each individual message.

There may also be no receivers listening, in which case the message stays in the queue until a receiver attaches itself to the queue to retrieve messages.

In the publish-and-subscribe model, messages not flagged as reliable can be discarded if no subscribers are registered to receive them at the time they are published.

Reference