lundi 3 août 2015

Websocket vs stocking session scoped bean

I have to notify clients of new entries in my database. Naturally I think about websocket to have a two waypoints communication. In an EJB I keep a list of all the javax.websocket.Session and then I do session.getBasicRemote().sendText("new notifcation"); for each of them. But I was wondering, instead of using websockets, why not stock all the current session scoped beans in a daemon (like a @Singleton EJB) and then notify all these beans ? Then the beans would notify their client using something like

RequestContext.getCurrentInstance().execute("console.log('new notification")

Aucun commentaire:

Enregistrer un commentaire