Push Notifications on Java EE 5

This is a way to have “server push” notifications to the client’s browser without having AsyncContext available.

With a distributed network system, you can’t just store notification messages into the cache and retrieve it quickly by polling the server from client.

The solution described uses Quartz Scheduler or something else to enable the Application Server to data synchronize with the database and store it in its cache (flow A, B, and C).

This way when the client polls the server (flow 0 and 1), it goes straight for the cache (flow 2) so it won’t use up the thread of the App Server since database functions take a long time (especially in large scale scenarios). The drawback to this is if this certain client has a message then it has to do a database delete record (flow 5) which takes a lot of time, comparatively to case when there are no records found. A way around this is to have another scheduler to do the deletes before we get the next iteration of sync from the first scheduler.

notification_javaee5.png

HINT: The poll interval should be around ½ of the scheduler interval since there is no point in polling the cache when it is not populated properly by the scheduler.

 
14
Kudos
 
14
Kudos

Now read this

Using Angular $compile to Escape Watcher Hell

This is a blog on how to handle repeating directive elements without using the ng-repeat directive when using AngularJS. We’ll keep this blog high level and assume the reader knows Angular development. Sample: <div ng-repeat='spell in... Continue →