Server-sent events in fluent-http

Today, I’ve added the initial support of Server-sent events in fluent-http.

The underlying http server we use (Simple) doesn’t support websockets yet. But streaming good-old server-sent events works very well.

To produce a stream of messages, we rely on the Java 8 Stream API.

Here’s a sample

This code streams the values 0,1,2,3,4,5… for ever.

Have fun!

2 thoughts on “Server-sent events in fluent-http”

  1. I’m almost sure we could use undertow instead of simple for fluent http.
    Thus you would easily get websocket support. And by adding a jar you could add servlet support and thus jaxrs if you need it.

    1. Yes, I tried already. It’s almost ok. We recently had to hide the use of simple behind facades. We’ll wait a bit for websocket support in Simple. If it never comes, we’ll use another web server. Undertow is a good candidate.

Comments are closed.