Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSE Java 11+ client example (w/o dependencies)

I'm looking for examples using a plain JDK11+ http client reading server sent events, without extra dependencies. I can't find anything about sse in the documentation either.

Any hints?

like image 890
bart van deenen Avatar asked Apr 26 '26 05:04

bart van deenen


1 Answers

Java 11 based implementation of SSE (Server-sent Events) client here:
SSE Client

It provides a pretty simple usage of processing of SSE messages.

Example usage:

EventHandler eventHandler = eventText -> { process(eventText); };
        SSEClient sseClient = 
SSEClient sseClient = SSEClient.builder().url(url).eventHandler(eventHandler)
    .build();
sseClient.start();

Note: I am the author of this SSE client.

like image 134
Liran Avatar answered Apr 29 '26 04:04

Liran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!