sse-eventbus demo without Spring Boot
  • HTML 68.8%
  • Java 31.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Ralph Schaer 0492468d36 upgrade
2026-09-25 06:43:09 +02:00
.mvn/wrapper upgrade 2026-05-31 15:49:32 +02:00
src/main upgrade 2026-06-27 18:16:13 +02:00
.gitignore Initial commit 2019-08-16 19:48:17 +02:00
mvnw Upgrade 2025-07-26 12:40:01 +02:00
mvnw.cmd Upgrade 2025-07-26 12:40:01 +02:00
pom.xml upgrade 2026-09-25 06:43:09 +02:00
README.md update README, upgrade dependencies, and add HTML client for SSE demo 2026-06-21 04:23:41 +02:00

SSE Spring Boot Demo

Small sse-eventbus demo using Spring Boot.

The application publishes server-sent events every five seconds and includes a small browser client served by Spring Boot.

Requirements

  • Java 25 or newer
  • Maven Wrapper included in this repository

Run

./mvnw spring-boot:run

On Windows:

.\mvnw.cmd spring-boot:run

Browser Client

After the application starts, open:

http://localhost:8080/

The page lets you enter a client id, connect to the backend, disconnect, and view the two event streams published by the demo.

SSE Endpoint

The browser client connects to this endpoint:

GET http://localhost:8080/register/{id}

{id} is the client id used by sse-eventbus.

The endpoint subscribes the client to these events:

  • message: JSON array with five random integers from 0 to 30
  • dto: JSON object, currently {"i":10,"s":"test"}

The first events are published after an initial two-second delay. New events are published every five seconds after that.

Custom Client Example

const source = new EventSource("http://localhost:8080/register/demo-client");

source.onmessage = event => {
  console.log("message", JSON.parse(event.data));
};

source.addEventListener("dto", event => {
  console.log("dto", JSON.parse(event.data));
});