Date: Tue, 19 Mar 2024 08:59:51 +0000 (UTC) Message-ID: <1608003359.56017.1710838791169@cwiki-he-fi.apache.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_56016_1151831376.1710838791169" ------=_Part_56016_1151831376.1710838791169 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
In Geronimo, you can configure OpenEJB for failover scenarios, such as multipoint and multicas= t. Further more, Geronimo uses WADI to support failover for Stateful Sessio= n Bean (SFSB) in a unicast way.
By default, OpenEJB can use either multicast or multipoint strategies for failover scenarios. Basically the serve= r cluster members maintain membership information using heartbeats and the = ejb client maintains a list of servers to change target server based on ava= ilability. Each heartbeat packet contains a single URI that advertises a se= rvice, its cluster group, and its location in the form of "cluster1:ejb:ejb= d://thehost:4201".
By updating different attributes in the config-substitutions.prope=
rties
file, you can choose the appropriate discovery strategies in y=
our cluster.
Multicast |
MultiPoint |
---|---|
ServerHostname=3D<LocalIP> |
ServerHostname=3D<LocalIP> |
where
Note that for multicast scenario, you have to set openejb.client.r=
equestretry property
to true when starting up the Geronimo =
server. For example
./geronimo.sh run --long -Dopenejb.client.requestretry=3Dtrue
EJB clients must know the address of EJB members to make sure that its r= equest will be handled with high availability, regardless of whether EJB me= mbers are clustered in a Multipoint or Multicast= strong> way.
See the following code snippet for your client application development f= or remote host lookup.
Properties p = =3D new Properties(); p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.R= emoteInitialContextFactory"); p.setProperty(Context.PROVIDER_URL,"multicast://239.255.3.2:6142?group=3Dcl= uster1"); ...
Properties p = =3D new Properties(); p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.R= emoteInitialContextFactory"); p.setProperty(Context.PROVIDER_URL,"failover:ejbd://ejbd://foo:4201"); ...
OpenEJB supports 3 kinds of failover strategies when the original node w= as shut down abnormally.
Properties p = =3D new Properties(); p.setProperty(Context.PROVIDER_URL,"failover:round-robin:ejbd://foo:4201,ej= bds://bar:4201,multicast://239.255.2.3:6142"); ...
Properties p = =3D new Properties(); p.setProperty(Context.PROVIDER_URL,"failover:ejbd://foo:4201,ejbd://bar:420= 1"); ...
Properties p = =3D new Properties(); p.setProperty(Context.PROVIDER_URL,"failover:random:ejbd://foo:4201,ejbd://= bar:4201"); ...
You can configure unicast-based support for EJB cluster= ing. WADI can be configured to use unicast instead of multicast to support = failover for Stateless Session Bean.
The following server configurations, shipped out-of-the-box with the Jav= a EE assemblies, must be installed and enabled for the unicast EJB failover= to work:
This configuration must be running when a cluster is started. If it is n= ot, then the substitution group openejb-clustering-wadi is not pro= perly recognized and the deployment fails.
To enable unicast-based failover for Stateless Session Bean, the w=
adi-clustering
module in <GERONIMO_HOME>/var/config/conf=
ig.xml
should be configured for each server node. You must specify t=
he real IP address to ServerHostname and the node name to Clus=
terNodeName for each static member in the config-substitutions.p=
roperties
file. Each member has its own GBean configuration in the <=
code>wadi-cluster module in config.xml
. Ensure that you=
define all the static members in it. The following example shows the confi=
guration with two static members.
... <module name=3D"org.apache.geronimo.configs/wadi-clustering/3.0-SNAPSHOT= /car"> =09<gbean name=3D"DefaultBackingStrategyFactory"> =09=09<attribute name=3D"nbReplica">${ReplicaCount}</attribute> =09</gbean> =09<gbean name=3D"DefaultDispatcherHolder"> =09=09<attribute name=3D"disableMCastService">true</attribute> =09=09<attribute name=3D"receiverPort">4002</attribute> =09=09<attribute name=3D"endPointURI">${EndPointURI}</attribute>= ; =09=09<attribute name=3D"clusterName">${WADIClusterName}</attribut= e> =09=09<reference name=3D"staticMember"> =09=09=09<pattern> =09=09=09=09<groupId>org.apache.geronimo.configs</groupId> =09=09=09=09<artifactId>wadi-clustering</artifactId> =09=09=09=09<version>2.2.1-SNAPSHOT</version> =09=09=09=09<type>car</type> =09=09=09=09<name>firstStaticMember</name> =09=09=09</pattern> =09=09</reference> =09</gbean> =09<gbean name=3D"org.apache.geronimo.configs/wadi-clustering/3.0-SNAPSH= OT/car?ServiceModule=3Dorg.apache.geronimo.configs/wadi-clustering/3.0-SNAP= SHOT/car,j2eeType=3DGBean,name=3DfirstStaticMember" =09=09gbeanInfo=3D"org.apache.geronimo.clustering.wadi.WadiStaticMember">= ; =09=09<attribute name=3D"className">org.apache.catalina.tribes.member= ship.StaticMember</attribute> =09=09<attribute name=3D"port">4002</attribute> =09=09<attribute name=3D"securePort">-1</attribute> =09=09<attribute name=3D"domain">test-domain</attribute> =09=09<attribute name=3D"UniqueId">0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0<= ;/attribute> =09=09<attribute name=3D"host">Node1_IP</attribute> =09=09<reference name=3D"nextWadiStaticMember"> =09=09=09<pattern> =09=09=09=09<groupId>org.apache.geronimo.configs</groupId> =09=09=09=09<artifactId>wadi-clustering</artifactId> =09=09=09=09<version>2.2.1-SNAPSHOT</version> =09=09=09=09<type>car</type> =09=09=09=09<name>secondStaticMember</name> =09=09=09</pattern> =09=09</reference> =09</gbean> =09<gbean name=3D"org.apache.geronimo.configs/wadi-clustering/3.0-SNAPSH= OT/car?ServiceModule=3Dorg.apache.geronimo.configs/wadi-clustering/3.0-SNAP= SHOT/car,j2eeType=3DGBean,name=3DsecondStaticMember" =09=09gbeanInfo=3D"org.apache.geronimo.clustering.wadi.WadiStaticMember">= ; =09=09<attribute name=3D"className">org.apache.catalina.tribes.member= ship.StaticMember</attribute> =09=09<attribute name=3D"port">4003</attribute> =09=09<attribute name=3D"securePort">-1</attribute> =09=09<attribute name=3D"domain">test-domain</attribute> =09=09<attribute name=3D"UniqueId">0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1<= ;/attribute> =09=09<attribute name=3D"host">Node2_IP</attribute> =09=09<reference name=3D"nextWadiStaticMember" /> =09</gbean> </module> ...
where
Node1_IP is the IP address of the first server node.
Nod=
e2_IP is the IP address of the second server node.
The Geronimo-specific deployment plan for an EJB application, which is u= sually packaged as an EJB JAR file, is called "openejb-jar.xml". The openejb-jar.xml deployment plan is used in conj= unction with the ejb-jar.xml Java EE deployment plan to de= ploy enterprise applications to the Geronimo application server.
To enable WADI configuration for your application, add openejb-clu=
stering-wadi
into the deployment plan as follows:
<ejb-jar x= mlns=3D"http://geronimo.apache.org/xml/ns/j2ee/ejb/openejb-2.0"=20 xmlns:wadi=3D"http://geronimo.apache.org/xml/ns/openejb-clustering= -wadi-1.2">=20 ... <wadi:openejb-clustering-wadi> <wadi:deltaReplication>false</wadi:deltaReplication> </wadi:openejb-clustering-wadi> </ejb-jar>
An application client must find an EJB node and make sure that the clien= t could find another node when the original one was shut down abnormally in= a unicast scenario. Use the following code snippet when programming your c= lient applications.
Properties p = =3D new Properties(); p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.R= emoteInitialContextFactory"); p.setProperty(Context.PROVIDER_URL,"ejbd://foo:4201"); =20 Context context1 =3D new InitialContext(p); ... p.setProperty(Context.PROVIDER_URL,"ejbd://bar:4201"); Context context2 =3D new InitialContext(p);