I'm trying to come up with a way to create a notification system in my
JSF application that mimics a push notification setup. Currently, I have a table set up in Oracle that contains notifications. When a user logs into the system, as part of the authentication process, I hit that table to see if there's any messages for that user, and I show them in a modal dialog upon login.
I would like to update this to also show any notifications that occur during the user's session. They might start a process that takes a while, and go about their business. When that process finishes, I'd like to be able to show a notification right away as opposed to them seeing the notification at next login. I could set up an ajax poller to check that table every minute or so, but that seems overkill. One of my team mates had an interesting idea, but we're not sure how to pull it off, so I'm looking for some input.
His idea was to have a Boolean stored in session. The Boolean would say whether or not there were new notifications added. Any process that adds new notifications would put a message on a JMS topic which would set that Boolean to true. There would be an ajax poller to check that Boolean every minute or so. If the Boolean gets set to "true", we'd make a database call at that time, check & display notifications, and set the Boolean to "false" again.
This means we're not hitting the database every minute unnecessarily, and checking a Boolean in the session costs nothing. If you haven't guessed it yet, the problem comes in when you try to figure out how to get an MDB to update a session variable. Is there some sort of stateful
EJB I can set up that can be read by the user's session, as well as updated by a MDB? Or does anyone have an idea for a better implementation that would work?
Here's what I'm working with:
JSF 2
EJB 3
PrimeFaces 5.1
Websphere
In the company I work for, it's tough to get them to sign off on open source solutions, so this needs to be something in-house. Any ideas are appreciated!