Can I subscribe to an SseEmitter in Java

Viewed 246

I am working on a Spring project in Java. We need ServerSentEvents there and using the SseEmitter looks like an easy way to send events to clients.

We also need to implement the Client in Java. Every tutorial I can find shows how to subscribe to the emitter in Javascript and the SseEmitter does not seem to have any subscription method. Does anyone know how I can listen to incoming events in Java?

2 Answers

Totally forgot about this, I found a solution. You can just receive the emitter as a Flux and subscribe to it in your client project. There you can handle the ServerSentEvents. So actually pretty easy but it's confusing to not receive the same thing you sent on the other side.

Related