Java Reference
In-Depth Information
SeatBookedException,NotEnoughMoneyException {
// Unchanged method
}
}
As you can see, the only relevant change to our stateful EJB is the
@org.jboss.ejb3.annotation.Clustered annotation, which is added at the
class level. We can also apply this annotation in the stateless EJB, which will add
load-balancing capabilities to your business methods, there by improving its scalab-
ility:
@Clustered
@Stateless
@Remote(TheatreInfo.class)
public class TheatreInfoBean implements
TheatreInfo {
@EJB TheatreBox box;
@Override
public StringBuffer printSeatList() {
// Unchanged method
}
}
As it is, our Ticket application is ready to be deployed in a cluster; however, there's
a last pitfall. As a matter of fact, the singleton EJB used to hold the cache of seat
will be instantiated once in each JVM of the cluster. This means that if there's a serv-
er failure, the data in the cache will be lost and a new one (unsynchronized) will be
used.
There are several alternatives to set up a cache in a clustered environment:
• Use a JBoss proprietary solution that is deploying a clustered version
of SingletonService , which exposes an HA-singleton of
Search WWH ::




Custom Search