/spring-server-sent-event

Sample app explaining how server can send events periodically to client for single endpoint invocation

Primary LanguageJava

Sending events from Server using Spring

Server Sent Events is a mechanism of pushing data to client over HTTP or by using push server protocols. It is standardized as part of HTML5 by W3C.

Spring Web MVC framework has a class named SseEmitter which allows server to send out stream of data gradually (i.e. in chunks) after the client has invoked an endpoint and established a connection. It can be used to continously send message updates or continous data streams to clients for having enhanced user experience.

This is demonstrated with 2 applications -

  1. Spring 4.2 based implementation i.e. regular-sse
  2. Spring 5.0 based implementation using Reactive principle i.e. reactive-sse

Reference implementation based on Josh Long's Spring Tips