Published on ONJava.com (http://www.onjava.com/)
 See this if you're having trouble printing code examples

EJB 2 Clustering with Application Servers

by Tyler Jewell

The Enterprise JavaBeans (EJB) component model is becoming the component framework of choice for enterprise development among Java developers. The EJB specification goes to great lengths to define characteristics that give containers the ability to manage transactions, persistence, environment variables, resource connections, and other infrastructure services.

Missing from the specification, however, is any reference to techniques or standards for instrumenting EJBs as clustered objects. This aspect, which is required for any large-scale system, has been completely left to the application server vendors to instrument as a valued addition in their systems.

This article will provide a systematic breakdown of the different possibilities that application server vendors may incorporate into their systems to instrument clustered EJBs.

Some Clustering Terminology

Before delving into the analysis, let's define some terms:

How Application Servers Can Instrument EJBs

Vendors can provide four locations for clustering logic for an EJB:

The JNDI Naming Server has a bounded home stub. All of these locations have logic that vendors can insert. The home stub and remote stub are the most interesting aspects since both of these objects are downloaded by Java clients and run locally on a remote machine. Vendors can conceivably develop load balancing and fail over algorithms for EJBs that aren't even resident in their own server. Given all of the locations at which vendors can instrument one form of load balancing or failover logic, the permutation of options is enormous.

Figure 1 provides a graphical representation of the following bullets. Theoretically, here is what a vendor could instrument:

Options for clusterable EJBs.

Making Heads or Tails Out of All This

There are many ways to instrument and implement clustered EJBs. By now, you must be thinking, "Holy clustering, Batman! How do I know what to use and where?" The answer to this question lies within the capabilities of any single application server. No one application server vendor supports all of these configurations, but this article should give you a starting point to use when assessing the capabilities of different systems. Also, make sure you consult with your vendor to receive a list of their best practices for EJB clustering. Most vendors provide them as value adds to their clients.

This discussion is only a start to the many facets of EJB clustering. A more detailed and interesting discussion is to analyze the scenarios where it is permissible and (more importantly) impermissible for remote stubs to perform load balancing and failover freely. The type of EJB and its behavior directly correlates to the depth of clustering capability of a remote stub.

In my next article, I will investigate the nuances of session bean clustering for stateful and stateless session beans. The article will analyze remote stub load balancing, discuss the differences between idempotent and non-idempotent methods, and introduce the concept of user-definable, programmatic stub load balancing.

Tyler Jewell , Director, Technical Evangelism, BEA Systems Tyler oversees BEA's technology evangelism efforts that are focused on driving early adoption of strategic BEA technologies into the ISV and developer community.

Return to ONJava.com.

Copyright © 2009 O'Reilly Media, Inc.