ralscha / sse-eventbus

EventBus library for sending events from a Spring appliction to the web browser with SSE
Apache License 2.0
79 stars 26 forks source link

Distributed SseEventBus #23

Closed HJK181 closed 1 year ago

HJK181 commented 1 year ago

We successfully use your library in our project, with only one drawback: The service handling the SSE-Connections can't be scaled as the client registration(s) live in memory inside SseEventBus#clients map.

Therefore how would you solve the distribution problem? From what I see so far, I came up with the following:

  1. Use some Pub/Sub framework in between and let every running instance of the service subscribe to a topic where it receives events with the client ID matching the registered clients in the event bus. Those events are then forwarded to the EventBus#handleEvent method if the client ID is registered on the particular service.
  2. Extend the SseEventBusConfigurer in the library in order to also pass a custom clients Map. I think all other data structures inside SseEventBus can already be provided with different distributed data structures, e.g. Redis/Hazelcast implementation of distributed queues, SubscriptionRegistry...

Do you have any other suggestions?

Thank you for the great work.

ralscha commented 1 year ago

That sounds good. If you can provide a pull request I will merge it and release a new version. Unfortunately I currently don't have time to do the refactor.

I personaly don't use the library anymore.
I switched my project to Centrifugo. Highly recommend it, works amazing for realtime updates.

HJK181 commented 1 year ago

Thank you for the tip, I'll have a look at Centrifugo, looks promising. Nevertheless, I gave it a try https://github.com/ralscha/sse-eventbus/pull/24

HJK181 commented 1 year ago

Thanks for the quick response and the new release. Could you please also publish the artifact to maven central? https://mvnrepository.com/artifact/ch.rasc/sse-eventbus

Then, the issue can be closed :)

ralscha commented 1 year ago

It's released. Version 2.0.1

HJK181 commented 1 year ago

Still can't find it with the above link.

ralscha commented 1 year ago

https://central.sonatype.com/artifact/ch.rasc/sse-eventbus/2.0.1

On Wed, 30 Aug 2023, 12:02 HJK181, @.***> wrote:

Still can't find it with the above link.

— Reply to this email directly, view it on GitHub https://github.com/ralscha/sse-eventbus/issues/23#issuecomment-1698869326, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC26ID2CAMAFFZLA5ZPJIDXX4FUNANCNFSM6AAAAAA4C527OQ . You are receiving this because you modified the open/close state.Message ID: @.***>