Implementing and sending SSE broadcasts

In this section, we're going to take a look at creating SSE broadcaster instances. We're going to register SSE event sinks with this SSE broadcaster, and then we're going broadcast events to all registered sinks. Finally, we'll implement a simple HTML chat leveraging SSE.

There's a lot of ground to cover in this section. Let's get started and open our IDE. As usual, to get started, we will prepare a small skeleton project. First up, we will implement the BroadcastResource class, which is the server side for sending SSE broadcasts. We have a few things to do. We will inject the SSE @Context which we need to construct new events. The next thing we need to do is initialize an SSE broadcaster. For this, ...

Get Building RESTful Web Services with Java EE 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.