2

JBoss seems to have a pretty easy set of annotations/configurations for clustering and load balancing session beans, but I'm not seeing the same features in the GlassFish 3.x docs.

Let's say I have both MyStatefulBean and MyStatelessBean beans. For both of them, I want the following capabilities:

  • I want to be able to create a cluster of the bean (to any number or scale) and put them behind a software load balancer that will round robin the beans; and
  • If 1 of the clustered beans fails for any reason I want it taken out of the pool

Does GlassFish free/(community edition) even support this or would I have to implement this myself?

Tangential to the first question: does clustering/load-balancing even make sense form stateful beans? I don't think it does now that I think of it...but still the question applies to both types of beans until proven otherwise!

IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
  • Reading the docs, it seems that LoadBalancer is not included in the community edition. Unfortunately I can't tell you what this means in detail... if you have the chance to find out more information about this point, let us know ;-) – perissf Jul 05 '12 at 08:48
  • 1
    @perissf GlassFish Server Open Source Edition supports mod_jk for load balancing. The commercial product does come with a more feature-rich load balancing plugin. – John Clingan Jul 05 '12 at 16:49

2 Answers2

1

If you plan to invoke the beans via remote calls, this is the chapter in High Availability Guide you're looking for.

Failover of stateful beans makes sense, but load-balancing is also possible. Bear in mind that it has its limits, the greatest one being, that extended persistence context cannot be used.

  • The pool sizes for a bean is specified in EJB service settings and can be overrided in glassfish-ejb-jar.xml for specific bean
  • AFAIK this is what EJB Spec says - when a system exception occurs (this includes unchecked exceptions), the bean is destroyed.
pdudits
  • 896
  • 6
  • 9
1

First, you need to enable high availability for the application if you want to preserve the session state on failure. If using the admin console, there is a checkbox for this on the deploy app screen. If you are deploying from the command line, then use "asadmin deploy --availabilityenabled=true --target mycluster myapp.ear".

When the bean is looked up, the bean RMI proxy/stub that is generated has a list of all the clustered GlassFish instances that are available. The order of the servers is randomly generated, and the RMI stub will select the server at the top of the list. This is how the load is spread across the cluster. If the remote server fails, the next server in the list is selected. If the remote bean is a stateful session bean, then the session is preserved on failover.

As @pdudits mentions, please read the documentation on the subject for more in-depth coverage.

Hope this helps!

John Clingan
  • 3,324
  • 21
  • 13