Skip to main content
Version: 2.14

PubSub

What is PubSub#

Publish-subscribe is a messaging paradigm:

  • Producers send messages to specific brokers rather than directly to consumers.
  • Brokers cache messages sent by producers and then actively push them to subscribed consumers or pull them.

The system architectures use this pattern to decouple or handle high traffic scenarios.

In Apache APISIX, the most common scenario is handling north-south traffic from the server to the client. Combining it with a publish-subscribe system, we can achieve more robust features, such as real-time collaboration on online documents, online games, etc.

Architecture#

Currently, Apache APISIX supports WebSocket communication with the client, which can be any application that supports WebSocket, with Protocol Buffer as the serialization mechanism, see the protocol definition.

Supported messaging systems#

How to support other messaging systems#

Apache APISIX implement an extensible pubsub module, which is responsible for starting the WebSocket server, coding and decoding communication protocols, handling client commands, and adding support for the new messaging system.

Basic Steps#

  • Add new commands and response body definitions to pubsub.proto
  • Add a new option to the scheme configuration item in upstream
  • Add a new scheme judgment branch to http_access_phase
  • Implement the required message system instruction processing functions
  • Optional: Create plugins to support advanced configurations of this messaging system

Example#

TODO, an example will be added later to point out how to support other messaging systems.