What are event-based applications?
In contrast to traditional web applications, where we have a request-response pattern, in event-based applications, we are dealing with events. The server and client stay connected and each side can send events, which the other side listens to and reacts to.
The following diagram shows the difference between implementing a chat app in a request-response pattern versus an event-based pattern:
Figure 13.1 – A chat app implementation with request-response and event-based patterns
For example, to implement a chat application in a request-response pattern, we would need to regularly send a request to a GET /chat/messages
endpoint to refresh the list of messages sent in a chat room. This process of periodically sending requests is called short polling. To send a chat message, we would make a request to POST /chat/messages
. In an event-based pattern, we could instead send a chat.message
event from the client to the...