3

We're using Spring with Vaadin for a UI framework. We'd like to have our UI components listen to a global eventbus for events.

There are problem with this though, the the event systems we've looked at so far all use strong references for registering listeners. This means that even if Vaadin has released the component it will never be garbage collected, and creates a memory leak.

We've tried to use detach to unregister a component. The problem with this is that things like tabsheets detach components when you're not viewing them, so they don't get updates.

We've been using Google Guava EventBus and I've just been testing springs JMS support, and Reactor support. I couldn't get @JmsListener working with "prototype" and, both Guava and Reactor would leak memory in our use case.

Is there a good event system that uses weak references to retain listeners? or is there a good place to hook an unregister into vaadin? are there perhaps patterns that I'm not thinking of that could help us solve this problem?

note: I realize the questions sound unfocused I'm looking for a solution to the problem and trying to avoid narrowing answers to only what I think the right answer should be.

xenoterracide
  • 16,274
  • 24
  • 118
  • 243
  • Did you try https://github.com/peholmst/vaadin4spring/tree/master/addons/eventbus ?? – Gokhan Oner Sep 15 '15 at 20:40
  • this answer has some longer bits about the reasons why mbassador was chosen: http://stackoverflow.com/a/27872769/3181392 – cfrick Sep 16 '15 at 08:32
  • @GokhanOner after reading the docs and picking through the code, it's unclear whether it solves the problem or reduces it, or neither. I filed a bug for them to document on how references are managed for subscribers. – xenoterracide Sep 16 '15 at 15:18
  • @cfrick that's very interesting, I've made mbassador my recommendation for our issue, as I'm out of time for investigating it. We still need to do some exploratory coding on it. – xenoterracide Sep 16 '15 at 15:19
  • note: if anyone has any answers though we'll be looking at this again in the future. – xenoterracide Sep 16 '15 at 15:21
  • @xenoterracide I having the same problem, how did u fix this? – Fabio Ebner Nov 22 '18 at 17:17
  • Mbassador is the only event bus I found that smart enough to use weak references. Otherwise we use on attach on detach listeners. – xenoterracide Nov 22 '18 at 17:43

0 Answers0