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.

 
10
Kudos
 
10
Kudos

Now read this

Retrospective on Appcelerator Titanium and Alloy

Working as a Front-End JavaScript developer there would naturally come a time when you would need to work on a mobile solution. There are couple of ways to handle it, from writing a pure website for your users to access your content to... Continue →