Java Reference
In-Depth Information
Deploying clustered applications
If you have tried starting your standalone or domain set of cluster nodes, you will be
surprised that there is no information at all about clustering in your server logging. Be-
lieve it, it is not a bug, but a feature! One of the key features of JBoss AS 7 is that only
a minimal set of services is started; therefore, in order to see a cluster's live demon-
stration, you need to deploy a cluster-aware application. In order to trigger clustering
libraries in your application, you can follow two approaches:
• If your application uses Enterprise JavaBeans, you can tag it as cluster-
able by adding a JBoss proprietary annota-
tion, (@org.jboss.ejb3.annotation.Clustered ), or via the EJB
configuration file ( jboss-ejb3.xml )
• If your application includes a web application archive, you can use the
portable <distributable /> element in your web.xml file. Let's see
both the approaches, starting from clustering EJBs.
Clustering EJBs
All that is necessary to cluster an EJB is to mark (annotate) the EJB component expli-
citly as clustered by adding the @org.jboss.ejb3.annotation.Clustered
annotation to your EJB at the class level. You can apply this annotation on your state-
less EJB, enabling load balancing over the cluster nodes for a remote client:
@Stateless
@Clustered
public class StatelessLBBean
{
public void doSomething()
{
// Do something
}
}
On the other hand, marking a stateful EJB enables, in addition to load balancing, the
replication of session data between the cluster nodes:
Search WWH ::




Custom Search