Here's a recurrent problem that I have and I think maybe CDI events can help me but I'm not sure.
I have two users interacting in a website, I want them to share an instance of a bean so they can both share an activity. So far the only way I know how to do this is by pushing data to the database then having two different beans, one for each user, continuosly check for changes.
My question is, if a sessionscoped bean observes an event, do every sessionbean of every user get notified when i fire it? Or only the session bean for the active user?. Because then I could use observer to keep an object syncronized for both users. However I don't really think this is the way it works because if I have a thousand sessions firing an event would incur in a 1000 method calls...
My other solution would be a huge application scoped bean that holds the activity object for both users, then any change made to it can be communicated to the users, but, I still have to be scanning this object, am I missing something?
You won't get it for free like that, because when the event is fired one and only one session is active for the current thread, and the actual object the observer method is called on [if non-static] is obtained from the active context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With