<html>
<head>
<base href="https://cwiki.apache.org/confluence">
<link rel="stylesheet" href="/confluence/s/2036/9/4/_/styles/combined.css?spaceKey=GMOxDOC30&forWysiwyg=true"
type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://cwiki.apache.org/confluence/display/GMOxDOC30/EJB+failover">EJB
failover</a></h2>
<h4>Page <b>edited</b> by <a href="https://cwiki.apache.org/confluence/display/~maojia508">maojia</a>
</h4>
<br/>
<h4>Changes (10)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >By default, OpenEJB can use either
*multicast* or *multipoint* strategies for failover scenarios. Basically the server cluster
members maintain membership information using heartbeats and the ejb client maintains a list
of servers to change target server based on availability. Each heartbeat packet contains a
single URI that advertises a service, its cluster group, and its location in the form of "cluster1:ejb:ejbd://thehost:4201".
<br> <br></td></tr>
<tr><td class="diff-changed-lines" >By updating different attributes
in <span class="diff-added-words"style="background-color: #dfd;">the</span> {{config-substitutions.properties}}
file, you can choose <span class="diff-added-words"style="background-color: #dfd;">the</span>
appropriate discovery strategies in your cluster. <br></td></tr>
<tr><td class="diff-unchanged" >||Multicast || MultiPoint|| <br>|
ServerHostname=<LocalIP>\\ <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >* _port_ is the port number used to
communicate with remote node. The port must not be the default openEJB server port 4201. <br>
<br></td></tr>
<tr><td class="diff-changed-lines" >Note that for multicast scenario,
you have to set {{openejb.client.requestretry property}} to _true_ when starting up <span
class="diff-added-words"style="background-color: #dfd;">the</span> Geronimo server.
For example <br></td></tr>
<tr><td class="diff-unchanged" >{panel} <br>./geronimo.sh run
--long -Dopenejb.client.requestretry=true <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > <br>h2. Developing the client
<br></td></tr>
<tr><td class="diff-changed-lines" >EJB clients must know the address
of EJB members to make sure that its request will be handled with high <span class="diff-changed-words">availability<span
class="diff-added-chars"style="background-color: #dfd;">,</span></span> regardless
<span class="diff-added-words"style="background-color: #dfd;">of whether</span>
EJB members are clustered in <span class="diff-added-words"style="background-color: #dfd;">a</span>
*Multipoint* or *Multicast* way. <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Refer
to</span> <span class="diff-added-words"style="background-color: #dfd;">See</span>
the following code snippet for your client application development for remote host lookup.
<br></td></tr>
<tr><td class="diff-unchanged" >{section} <br>{column:width=50%}
<br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > <br>h2. failover strategies
<br></td></tr>
<tr><td class="diff-changed-lines" >OpenEJB supports 3 kinds of failover
strategies when the original node was <span class="diff-changed-words">shut<span
class="diff-added-chars"style="background-color: #dfd;"> </span>down</span>
abnormally. <br></td></tr>
<tr><td class="diff-unchanged" > <br>{code:title=round-robin}
<br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >h2. Understanding unicast support
in Geronimo <br> <br></td></tr>
<tr><td class="diff-changed-lines" >The following server configurations,
shipped out-of-the-box with the Java EE assemblies, must be installed and enabled for <span
class="diff-added-words"style="background-color: #dfd;">the</span> unicast EJB failover
to work: <br></td></tr>
<tr><td class="diff-unchanged" >* _org.apache.geronimo.configs/openejb-clustering-wadi//car_:
it defines runtime dependencies and OpenEJB clustering contracts. <br>* _org.apache.geronimo.configs/openejb-clustering-builder-wadi//car_:
it defines deployment time dependencies along with a _OpenEJBClusteringBuilder_ GBean declaring
the default clustering configuration. <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > <br>h2. Enabling unicast support
in Geronimo <br></td></tr>
<tr><td class="diff-changed-lines" >To enable unicast-based failover
for Stateless Session Bean, the {{wadi-clustering}} module in {{<GERONIMO_HOME>/var/config/config.xml}}
should be configured for each server node. You must specify the real IP address to _ServerHostname_
and the node name to _ClusterNodeName_ for each static member in <span class="diff-added-words"style="background-color:
#dfd;">the</span> {{config-substitutions.properties}} file. Each member has its own
GBean configuration in the {{wadi-cluster}} module in {{config.xml}}. Ensure that you define
all the static members in it. The following example shows the configuration with two static
members. <br></td></tr>
<tr><td class="diff-unchanged" >{code:xml} <br>... <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >h2. Configuring the application <br>
<br></td></tr>
<tr><td class="diff-changed-lines" >The Geronimo-specific deployment
plan for an EJB application, which is usually packaged as an EJB JAR file, is called *"openejb-jar.xml"*.
The *openejb-jar.xml* deployment plan is used <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">to</span>
in conjunction with the *ejb-jar.xml* Java EE deployment plan to deploy enterprise applications
to the Geronimo application server. <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-changed-lines" >To enable WADI configuration for
your application, add {{openejb-clustering-wadi}} into the deployment plan as <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">followed:</span>
<span class="diff-added-words"style="background-color: #dfd;">follows:</span>
<br></td></tr>
<tr><td class="diff-unchanged" >{code:xml} <br><ejb-jar
xmlns="http://geronimo.apache.org/xml/ns/j2ee/ejb/openejb-2.0" <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >h2. Configuring the client <br>
<br></td></tr>
<tr><td class="diff-changed-lines" >An application client must find
an EJB node and make sure <span class="diff-added-words"style="background-color: #dfd;">that</span>
the client could find another node when the original one was shut down abnormally in a unicast
scenario. Use the following code snippet when programming your client applications. <br></td></tr>
<tr><td class="diff-unchanged" >{code:java} <br>Properties p
= new Properties(); <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<style type='text/css'>/*<![CDATA[*/
table.ScrollbarTable {border: none;padding: 3px;width: 100%;padding: 3px;margin: 0px;background-color:
#f0f0f0}
table.ScrollbarTable td.ScrollbarPrevIcon {text-align: center;width: 16px;border: none;}
table.ScrollbarTable td.ScrollbarPrevName {text-align: left;border: none;}
table.ScrollbarTable td.ScrollbarParent {text-align: center;border: none;}
table.ScrollbarTable td.ScrollbarNextName {text-align: right;border: none;}
table.ScrollbarTable td.ScrollbarNextIcon {text-align: center;width: 16px;border: none;}
/*]]>*/</style><div class="Scrollbar"><table class='ScrollbarTable'><tr><td
width='33%' class='ScrollbarPrevName'> </td><td width='33%' class='ScrollbarParent'><sup><a
href="/confluence/display/GMOxDOC30/Clustering+and+farming"><img border='0' align='middle'
src='/confluence/images/icons/up_16.gif' width='8' height='8'></a></sup><a
href="/confluence/display/GMOxDOC30/Clustering+and+farming">Clustering and farming</a></td><td
width='33%' class='ScrollbarNextName'> <a href="/confluence/display/GMOxDOC30/Farming+using+Deployment">Farming
using Deployment</a></td><td class='ScrollbarNextIcon'><a href="/confluence/display/GMOxDOC30/Farming+using+Deployment"><img
border='0' align='middle' src='/confluence/images/icons/forwd_16.gif' width='16' height='16'></a></td></tr></table></div>
<p>In Geronimo, you can configure <a href="http://openejb.apache.org/3.0/failover.html"
title="OpenEJB failover" class="external-link" rel="nofollow">OpenEJB for failover scenarios</a>,
such as multipoint and multicast. Further more, Geronimo uses WADI to support failover for
Stateful Session Bean (SFSB) in a unicast way.</p>
<div>
<ul>
<li><a href='#EJBfailover-Enablingmultipoint%2Fmulticastfailover'>Enabling
multipoint/multicast failover</a></li>
<ul>
<li><a href='#EJBfailover-Developingtheclient'>Developing the client</a></li>
<li><a href='#EJBfailover-failoverstrategies'>failover strategies</a></li>
</ul>
<li><a href='#EJBfailover-Enablingunicastfailover'>Enabling unicast failover</a></li>
<ul>
<li><a href='#EJBfailover-UnderstandingunicastsupportinGeronimo'>Understanding
unicast support in Geronimo</a></li>
<li><a href='#EJBfailover-EnablingunicastsupportinGeronimo'>Enabling unicast
support in Geronimo</a></li>
<li><a href='#EJBfailover-Configuringtheapplication'>Configuring the application</a></li>
<li><a href='#EJBfailover-Configuringtheclient'>Configuring the client</a></li>
</ul>
</ul></div>
<h1><a name="EJBfailover-Enablingmultipoint%2Fmulticastfailover"></a>Enabling
multipoint/multicast failover </h1>
<p>By default, OpenEJB can use either <b>multicast</b> or <b>multipoint</b>
strategies for failover scenarios. Basically the server cluster members maintain membership
information using heartbeats and the ejb client maintains a list of servers to change target
server based on availability. Each heartbeat packet contains a single URI that advertises
a service, its cluster group, and its location in the form of "cluster1:ejb:ejbd://thehost:4201".
</p>
<p>By updating different attributes in the <tt>config-substitutions.properties</tt>
file, you can choose the appropriate discovery strategies in your cluster.</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Multicast </th>
<th class='confluenceTh'> MultiPoint</th>
</tr>
<tr>
<td class='confluenceTd'> ServerHostname=<LocalIP><br class="atl-forced-newline"
/>
MulticastEnabled=true </td>
<td class='confluenceTd'> ServerHostname=<LocalIP><br class="atl-forced-newline"
/>
MultipointEnable=true<br class="atl-forced-newline" />
MultipointServers=<Remotehost/IP>:<port></td>
</tr>
</tbody></table>
</div>
<p>where </p>
<ul>
<li><em>LocalIP</em> is the ip address of the current node</li>
<li><em>Remotehost/IP</em> is the host name or IP address of EJB member(s)
in a cluster.</li>
<li><em>port</em> is the port number used to communicate with remote node.
The port must not be the default openEJB server port 4201.</li>
</ul>
<p>Note that for multicast scenario, you have to set <tt>openejb.client.requestretry
property</tt> to <em>true</em> when starting up the Geronimo server. For
example</p>
<div class="panel" style="border-width: 1px;"><div class="panelContent">
<p>./geronimo.sh run --long -Dopenejb.client.requestretry=true</p>
</div></div>
<h2><a name="EJBfailover-Developingtheclient"></a>Developing the client</h2>
<p>EJB clients must know the address of EJB members to make sure that its request will
be handled with high availability, regardless of whether EJB members are clustered in a <b>Multipoint</b>
or <b>Multicast</b> way.</p>
<p>See the following code snippet for your client application development for remote
host lookup.</p>
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr>
<td class="confluenceTd" valign="top" width="50%">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>URI for Multicast</b></div><div
class="codeContent panelContent">
<pre class="code-java">
Properties p = <span class="code-keyword">new</span> Properties();
p.setProperty(Context.INITIAL_CONTEXT_FACTORY, <span class="code-quote">"org.apache.openejb.client.RemoteInitialContextFactory"</span>);
p.setProperty(Context.PROVIDER_URL,<span class="code-quote">"multicast:<span class="code-comment">//239.255.3.2:6142?group=cluster1"</span>);
</span>...
</pre>
</div></div></td>
<td class="confluenceTd" valign="top" width="50%">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>URI for Multipoint/Unicast</b></div><div
class="codeContent panelContent">
<pre class="code-java">
Properties p = <span class="code-keyword">new</span> Properties();
p.setProperty(Context.INITIAL_CONTEXT_FACTORY, <span class="code-quote">"org.apache.openejb.client.RemoteInitialContextFactory"</span>);
p.setProperty(Context.PROVIDER_URL,<span class="code-quote">"failover:ejbd:<span
class="code-comment">//ejbd://foo:4201"</span>);
</span>...
</pre>
</div></div></td></tr></tbody></table>
<h2><a name="EJBfailover-failoverstrategies"></a>failover strategies </h2>
<p>OpenEJB supports 3 kinds of failover strategies when the original node was shut down
abnormally. </p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>round-robin</b></div><div class="codeContent
panelContent">
<pre class="code-java">
Properties p = <span class="code-keyword">new</span> Properties();
p.setProperty(Context.PROVIDER_URL,<span class="code-quote">"failover:round-robin:ejbd:<span
class="code-comment">//foo:4201,ejbds://bar:4201,multicast://239.255.2.3:6142"</span>);
</span>...
</pre>
</div></div>
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr>
<td class="confluenceTd" valign="top" width="50%">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>sticky</b></div><div class="codeContent
panelContent">
<pre class="code-java">
Properties p = <span class="code-keyword">new</span> Properties();
p.setProperty(Context.PROVIDER_URL,<span class="code-quote">"failover:ejbd:<span
class="code-comment">//foo:4201,ejbd://bar:4201"</span>);
</span>...
</pre>
</div></div></td>
<td class="confluenceTd" valign="top" width="50%">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>random</b></div><div class="codeContent
panelContent">
<pre class="code-java">
Properties p = <span class="code-keyword">new</span> Properties();
p.setProperty(Context.PROVIDER_URL,<span class="code-quote">"failover:random:ejbd:<span
class="code-comment">//foo:4201,ejbd://bar:4201"</span>);
</span>...
</pre>
</div></div></td></tr></tbody></table>
<h1><a name="EJBfailover-Enablingunicastfailover"></a>Enabling unicast failover
</h1>
<p>You can configure <b>unicast-based</b> support for EJB clustering. WADI
can be configured to use unicast instead of multicast to support failover for Stateless Session
Bean. </p>
<h2><a name="EJBfailover-UnderstandingunicastsupportinGeronimo"></a>Understanding
unicast support in Geronimo</h2>
<p>The following server configurations, shipped out-of-the-box with the Java EE assemblies,
must be installed and enabled for the unicast EJB failover to work:</p>
<ul>
<li><em>org.apache.geronimo.configs/openejb-clustering-wadi//car</em>:
it defines runtime dependencies and OpenEJB clustering contracts.</li>
<li><em>org.apache.geronimo.configs/openejb-clustering-builder-wadi//car</em>:
it defines deployment time dependencies along with a <em>OpenEJBClusteringBuilder</em>
GBean declaring the default clustering configuration.</li>
</ul>
<p>This configuration must be running when a cluster is started. If it is not, then
the substitution group <em>openejb-clustering-wadi</em> is not properly recognized
and the deployment fails.</p>
<h2><a name="EJBfailover-EnablingunicastsupportinGeronimo"></a>Enabling
unicast support in Geronimo</h2>
<p>To enable unicast-based failover for Stateless Session Bean, the <tt>wadi-clustering</tt>
module in <tt><GERONIMO_HOME>/var/config/config.xml</tt> should
be configured for each server node. You must specify the real IP address to <em>ServerHostname</em>
and the node name to <em>ClusterNodeName</em> for each static member in the <tt>config-substitutions.properties</tt>
file. Each member has its own GBean configuration in the <tt>wadi-cluster</tt>
module in <tt>config.xml</tt>. Ensure that you define all the static members in
it. The following example shows the configuration with two static members.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
...
<span class="code-tag"><module name=<span class="code-quote">"org.apache.geronimo.configs/wadi-clustering/3.0-SNAPSHOT/car"</span>></span>
<span class="code-tag"><gbean name=<span class="code-quote">"DefaultBackingStrategyFactory"</span>></span>
<span class="code-tag"><attribute name=<span class="code-quote">"nbReplica"</span>></span>${ReplicaCount}<span
class="code-tag"></attribute></span>
<span class="code-tag"></gbean></span>
<span class="code-tag"><gbean name=<span class="code-quote">"DefaultDispatcherHolder"</span>></span>
<span class="code-tag"><attribute name=<span class="code-quote">"disableMCastService"</span>></span>true<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"receiverPort"</span>></span>4002<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"endPointURI"</span>></span>${EndPointURI}<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"clusterName"</span>></span>${WADIClusterName}<span
class="code-tag"></attribute></span>
<span class="code-tag"><reference name=<span class="code-quote">"staticMember"</span>></span>
<span class="code-tag"><pattern></span>
<span class="code-tag"><groupId></span>org.apache.geronimo.configs<span
class="code-tag"></groupId></span>
<span class="code-tag"><artifactId></span>wadi-clustering<span
class="code-tag"></artifactId></span>
<span class="code-tag"><version></span>2.2.1-SNAPSHOT<span
class="code-tag"></version></span>
<span class="code-tag"><type></span>car<span class="code-tag"></type></span>
<span class="code-tag"><name></span>firstStaticMember<span
class="code-tag"></name></span>
<span class="code-tag"></pattern></span>
<span class="code-tag"></reference></span>
<span class="code-tag"></gbean></span>
<gbean name=<span class="code-quote">"org.apache.geronimo.configs/wadi-clustering/3.0-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/wadi-clustering/3.0-SNAPSHOT/car,j2eeType=GBean,name=firstStaticMember"</span>
gbeanInfo=<span class="code-quote">"org.apache.geronimo.clustering.wadi.WadiStaticMember"</span>>
<span class="code-tag"><attribute name=<span class="code-quote">"className"</span>></span>org.apache.catalina.tribes.membership.StaticMember<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"port"</span>></span>4002<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"securePort"</span>></span>-1<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"domain"</span>></span>test-domain<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"UniqueId"</span>></span>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"host"</span>></span>Node1_IP<span
class="code-tag"></attribute></span>
<span class="code-tag"><reference name=<span class="code-quote">"nextWadiStaticMember"</span>></span>
<span class="code-tag"><pattern></span>
<span class="code-tag"><groupId></span>org.apache.geronimo.configs<span
class="code-tag"></groupId></span>
<span class="code-tag"><artifactId></span>wadi-clustering<span
class="code-tag"></artifactId></span>
<span class="code-tag"><version></span>2.2.1-SNAPSHOT<span
class="code-tag"></version></span>
<span class="code-tag"><type></span>car<span class="code-tag"></type></span>
<span class="code-tag"><name></span>secondStaticMember<span
class="code-tag"></name></span>
<span class="code-tag"></pattern></span>
<span class="code-tag"></reference></span>
<span class="code-tag"></gbean></span>
<gbean name=<span class="code-quote">"org.apache.geronimo.configs/wadi-clustering/3.0-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/wadi-clustering/3.0-SNAPSHOT/car,j2eeType=GBean,name=secondStaticMember"</span>
gbeanInfo=<span class="code-quote">"org.apache.geronimo.clustering.wadi.WadiStaticMember"</span>>
<span class="code-tag"><attribute name=<span class="code-quote">"className"</span>></span>org.apache.catalina.tribes.membership.StaticMember<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"port"</span>></span>4003<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"securePort"</span>></span>-1<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"domain"</span>></span>test-domain<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"UniqueId"</span>></span>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1<span
class="code-tag"></attribute></span>
<span class="code-tag"><attribute name=<span class="code-quote">"host"</span>></span>Node2_IP<span
class="code-tag"></attribute></span>
<span class="code-tag"><reference name=<span class="code-quote">"nextWadiStaticMember"</span>
/></span>
<span class="code-tag"></gbean></span>
<span class="code-tag"></module></span>
...
</pre>
</div></div>
<p>where</p>
<p><em>Node1_IP</em> is the IP address of the first server node.<br/>
<em>Node2_IP</em> is the IP address of the second server node. </p>
<h2><a name="EJBfailover-Configuringtheapplication"></a>Configuring the
application</h2>
<p>The Geronimo-specific deployment plan for an EJB application, which is usually packaged
as an EJB JAR file, is called <b>"openejb-jar.xml"</b>. The <b>openejb-jar.xml</b>
deployment plan is used in conjunction with the <b>ejb-jar.xml</b> Java EE deployment
plan to deploy enterprise applications to the Geronimo application server. </p>
<p>To enable WADI configuration for your application, add <tt>openejb-clustering-wadi</tt>
into the deployment plan as follows:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<ejb-jar xmlns=<span class="code-quote">"http://geronimo.apache.org/xml/ns/j2ee/ejb/openejb-2.0"</span>
<span class="code-keyword">xmlns:wadi</span>=<span class="code-quote">"http://geronimo.apache.org/xml/ns/openejb-clustering-wadi-1.2"</span>>
...
<span class="code-tag"><wadi:openejb-clustering-wadi></span>
<span class="code-tag"><wadi:deltaReplication></span>false<span
class="code-tag"></wadi:deltaReplication></span>
<span class="code-tag"></wadi:openejb-clustering-wadi></span>
<span class="code-tag"></ejb-jar></span>
</pre>
</div></div>
<h2><a name="EJBfailover-Configuringtheclient"></a>Configuring the client</h2>
<p>An application client must find an EJB node and make sure that the client could find
another node when the original one was shut down abnormally in a unicast scenario. Use the
following code snippet when programming your client applications.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
Properties p = <span class="code-keyword">new</span> Properties();
p.setProperty(Context.INITIAL_CONTEXT_FACTORY, <span class="code-quote">"org.apache.openejb.client.RemoteInitialContextFactory"</span>);
p.setProperty(Context.PROVIDER_URL,<span class="code-quote">"ejbd:<span class="code-comment">//foo:4201"</span>);
</span>Context context1 = <span class="code-keyword">new</span> InitialContext(p);
...
p.setProperty(Context.PROVIDER_URL,<span class="code-quote">"ejbd:<span class="code-comment">//bar:4201"</span>);
</span>Context context2 = <span class="code-keyword">new</span> InitialContext(p);
</pre>
</div></div>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;">
<a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
</div>
<a href="https://cwiki.apache.org/confluence/display/GMOxDOC30/EJB+failover">View
Online</a>
|
<a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=23334723&revisedVersion=2&originalVersion=1">View
Changes</a>
|
<a href="https://cwiki.apache.org/confluence/display/GMOxDOC30/EJB+failover?showComments=true&showCommentArea=true#addcomment">Add
Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
|