Along with the Server API for SSE, JAX-RS 2.1 (part of Java EE 8) also has an equivalent client side API

Here is a quick peek – you can grab the project from Github

To summarize

we use a @Singleton EJB with @Startup

EJB with during initialization create a single action (one time) Timer i.e. @PostConstruct and instantiate the SSEEventSource – its a public SSE source

when the timer expires, the @Timeout annotated method gets triggered opens the SSE connection prints them out – this action is registered as a callback (written as a Java 8 lamda in this case)

annotated method gets triggered Execution thread pool(s) – notice this in the logs the timer itself is triggered in the EJB thread pool SSE event callbacks are executed in the ManagedExecutorService thread pool (thanks to Java EE Concurrency Utilities )



To run using Docker

Refer README

Further reading

Cheers!