users@glassfish.java.net

Re: Rich client dealing with cluster environment

From: <glassfish_at_javadesktop.org>
Date: Thu, 13 Sep 2007 13:05:47 PDT

Everything I know about the load balancing/fail-over topic I learned from Sheetal, who is one of the real experts in this. I'm sure she will correct any errors I make here.

By a stand-alone client, I assume you mean a Java SE application (not a Java EE application client) that wants to work with EJBs in clustered servers.

First, read the EJB FAQ that describes how to do this in the non-clustered case:

https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB

Steps 4 and 5 as described there will be a little different for load-balancing.

There are two aspects to load-balancing and failover: bootstrapping and actual EJB access. All the EJB access (client-to-EJB communication) uses RMI-IIOP, so what's key is getting your client connected to an ORB running in one of the clustered servers. That's the bootstrapping step.

In the EJB FAQ discussion, instead of setting the ORBInitialHost and ORBInitialPort properties, your command line or code needs to set the system property

com.sun.appserv.iiop.endpoints

to a value like this:

host1:port1,host2:port2

Each host is the host name where a server instance is running and each port number is the port where the ORB on that server is listening. Be sure to use the ORB port and not the HTTP listener or admin listener ports.

When your client instantiates the InitialContext, the client-side ORB code will use the com.sun.appserv.iiop.endpoints value for bootstrapping. That is, it will try to contact each of the host/port pairs listed there until one of them works. (There are discussions elsewhere in this forum describing what happens if no server-side ORB responds, how to configure that behavior, etc.)

One thing that's cool about load balancing and failover is that once your client's ORB has bootstrapped to one ORB, it will automatically know about all ORBs in the same cluster that are active. From then on the EJB access traffic will use that full set of ORBs, if needed, to find an instance of the required EJB.

There were some issues in earlier builds that have been fixed, so be sure to use a recent build.

- Tim
[Message sent by forum member 'tjquinn' (tjquinn)]

http://forums.java.net/jive/thread.jspa?messageID=235311