Ajax Push is a revolutionary capability of the ICEfaces framework that
enables asynchronous, web-based push of presentation changes to the
client browser based on server-side events. Any web application
where users are observing dynamic data can benefit, as Ajax Push brings
that data alive with dynamic, instantaneous updates. When
multiple users are interacting with the same data, Ajax Push enables
real-time collaborative features, because everyone can be instantly
aware of each others actions. Ajax Push is a fundamental
capability of the ICEfaces framework, available from the very first
release. The framework handles all of the low-level intricacies
of the push mechanism, providing the developer with a simple, pure Java
API for application development. This frees the developer to
focus on creative aspects of push-style application development.
Ajax Push In Action
The best way to understand the power of Ajax Push is to see it in action. ICEfaces
includes several examples of push-style collaborative applications such asAuction Monitor
andWebMC
.
Nuts and Bolts of Ajax Push
The underlying mechanism for Ajax Push is HTTP protocol inversion (also
known as long polling). This technique involves holding a
connection open from the browser client to the server with a blocking
request, and then fulfilling that request when some state change in
the application triggers an update to the presentation. This
mechanism is illustrated in the diagram below.
Based on this basic mechanism ICEfaces offers the following features.
Connection Heartbeating and
Monitoring:
In order to maintain potentially long-lived
connections, ICEfaces includes a configurable heart beat mechanism that
actively monitors the health of the connection, and provides alerts
when connection problems are detected.
Browser Connection Sharing:
Overcoming the connection limit associated with browsers, ICEfaces
facilitates sharing of the push connection between multiple views in
the same browser instance. This means that multiple tabs or
windows onto the same push-enabled application will work. It also means
that multiple push-enabled portlets within a page can coexist and share
the connection.
Optimized Rendering:
ICEfaces utilizes the JSF lifecycle to force rendering of clients
requiring an updated. The framework provides the necessary
synchronization, and optimizes rendering through request coalescing and
a configurable, bounded thread pool.
The Programming Model
While the underlying mechanism for Ajax Push is intricate, the
programming model provided in ICEfaces is simple. The key
elements of the ICEfaces Ajax Push mechanism are described and
illustrated below.
Render Manager:
The
Render Manager is an application scoped managed bean that coordinates
all render requests. It handles JSF lifecycle management, and
coalesces render requests to maximize performance. The Render
Manager also handles the registration and population of Render Groups.
Render Group:
A
Render Group is an object that is registered with the Render Manager,
and is used to organize groups of Renderables (clients) that will
receive the same push updates. Different types of render groups
such as on-demand, interval, and delay renderers are available.
Renderable:
Any
request or session scoped bean that implements the ICEfaces Renderable
interface, can be added to a Render Group, and participate in Ajax Push
events.
To add Ajax Push capabilities to your application you simply need to:
Add the Render Manager to your application's configuration.
Establish and populate Render Groups for different types of push
events that you need to support.
Request a render on a Render Group based on some trigger in your
application logic.
Scalable Asynchronous Request Processing
As described earlier, the underlying HTTP protocol inversion mechanism
used for Ajax Push requires an open connection per client
session. Under the standard Java Servlet model, this approach
does not scale well, as each connection requires its on thread of
execution. In order to overcome this thread per client dependency
a number of application servers include an Asynchronous Request
Processing (ARP) mechanism, and ICEfaces is integrated with these
mechanisms to ensure scalable deployment of push enabled
applications. The following ARP mechanisms are supported in
ICEfaces.
Apache Tomcat 6 Comet Processor
Sun Glassfish Grizzly Plugin
Jetty 6 Continuations
Push Server
ThePush Server
automatically configures your run time
environment for simple and effective deployment of Ajax Push style
applications and portlets under a single domain name. It manages a
single Ajax Push blocking connection, and shares it between an number of
ICEfaces applications and portlets. It also automatically detects and
utilizes the native ARP mechanism available within the application
server. You can learn more about the Push Serverhere
.