HTML and CSS Reference
In-Depth Information
Chapter 5
Using Messaging over
WebSocket with STOMP
In the previous chapter, we explored the concept of layering protocols over WebSocket
and some of the key benefits of layering a standards-based protocol over WebSocket.
Specifically, we looked at building a standard instant messaging and presence protocol,
XMPP, over WebSocket. In this chapter, we examine how to use a messaging protocol
with WebSocket.
Messaging is an architectural style characterized by sending asynchronous messages
between independent components, allowing you to build loosely coupled systems.
Messaging provides an abstraction layer for communication patterns, and thus is a very
flexible and powerful way to write networked applications.
Key players in messaging are the message broker and the clients. The message
broker accepts connections from the clients, handles messages coming from the clients,
and sends messages to them. The broker can also handle responsibilities such as
authentication, authorization, message encryption, reliable message delivery, message
throttling, and fanout. When clients connect to the message broker, they can send
messages to the broker, as well as receive messages sent by the broker to them. This
model is called publish/subscribe, where the message broker publishes a number of
messages and the client subscribes to all or, more commonly, a subset of the messages.
Messaging is widely used in enterprises as well to integrate disparate enterprise
applications. Besides loosely coupling enterprise systems, enterprise messaging focuses
on key enterprise requirements, including encryption, single sign-on, authorization, high
availability, and scalability.
Similar to how we layered XMPP over WebSocket, you can also layer a
publish/subscribe protocol over WebSocket. One example of a publish/subscribe
(or, colloquially, pub/sub) protocol is STOMP (Simple or Streaming Text Oriented
Messaging Protocol). Figure 5-1 shows a diagram of how STOMP over WebSocket relates
to the layering of other protocols.
Search WWH ::

Custom Search