HTML and CSS Reference
Figure 5-1. Layering STOMP over WebSocket
WebSocket is very well suited to a typical messaging architecture, where there may
be a high volume of messages flowing from the message broker to the client at fast rates.
For example, one typical use case for messaging is a client subscribing to foreign exchange
or stock information; in this case, the messages (the exchange rate, the stock value, and
so on) are very small but the client's receiving of the messages in real time and with low
latency is crucial to the success of the application. Based on what you've hopefully learned
in this topic so far, you can see how WebSocket is a great fit for such applications.
In this chapter, we'll examine pub/sub models, a widely used protocol (STOMP),
then walk through building your own pub/sub application—a game!—using STOMP over
WebSocket. We'll use the popular open source message broker Apache ActiveMQ and
explore some of the ways you can use STOMP with WebSocket in your own architecture.
■ The Text portion of the sToMP definition signifies that the protocol is text oriented.
Chapter 6, which focuses on the RFb protocol, describes how to use a binary-oriented
protocol over Websocket.
Overview of Publish and Subscribe Models
A common messaging pattern is the publish/subscribe pattern (pub/sub). In the
pub/sub pattern, clients connect to a broker that dispatches messages. A client can
publish messages to the broker and/or subscribe to one or more message feeds.
In the messaging world there are two frequently used message distribution
techniques, as shown in Figure 5-2 :