How does it work?

Publishers, subscribers, and brokers communicate with each other using command messages. These messages are used to do the following things:

Publisher and broker
The following communications take place between publishers and brokers:
  1. A publisher can register its intention to publish information about certain topics (this is optional: registration can take place with the first publication, or not at all, as described in Registering with the broker).
  2. A publisher sends publication messages to the broker, containing the publication data (or referring to it). The messages can be forwarded directly to the subscribers, or, in the case of retained publications, be held at the broker until requested by a subscriber.
  3. A publisher can send a message to the broker requesting that a retained publication held at the broker be deleted.
  4. A publisher can deregister with the broker when it has finished sending messages about a certain topic.
These interactions are all described in Writing publisher applications.
Subscriber and broker
The following communications take place between subscribers and brokers:
  1. A subscriber registers with a broker, specifying the topics that it is interested in.
  2. The broker sends to the subscriber subsequent publications that match the topics specified. Alternatively, the subscriber can request retained publications held at the broker.
  3. The subscriber can deregister with the broker for certain topics when it is no longer interested in them.
These interactions are all described in Writing subscriber applications.
Broker and broker
The following communications take place between brokers:
  1. Brokers can exchange subscription registrations and deregistrations.
  2. Brokers can exchange publications, and requests to delete publications.
  3. Brokers can exchange information about themselves.

These interactions are illustrated in Figure 3.

Figure 3. Communication between publishers, subscribers, and brokers
Communication between publishers, subscribers, and brokers