I have explained in my previous post in more detail about the cluster configuration and deployment of sample application. This post is the continuation to access the deployed application.
In order to access the application deployed in the Cluster
environment, we should access via HTTP web servers. We can configure apache HTTP
servers
or any other client proxy to access the
deployed application.
Simple flow diagram to understand the requests managed by Load Balancer
Simple flow diagram to understand the requests managed by Load Balancer
In this sample am
going use the HTTP proxy plugin ,
for that I have created the simple webapplication in JDeveloper and configured
the HttpClusterServlet and managed servlets details in web.xml and weblogic.xml.
Download web app here.
web.xml (sample and hihglighted important configs)
<?xml version = '1.0' encoding =
'windows-1252'?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
xmlns="http://java.sun.com/xml/ns/j2ee">
<servlet>
<servlet-name>HttpClusterServlet</servlet-name>
<servlet-class>
weblogic.servlet.proxy.HttpClusterServlet
</servlet-class>
<init-param>
<param-name>WebLogicCluster</param-name>
<param-value>localhost:7881|localhost:7882</param-value>
</init-param>
<init-param>
<param-name>KeyStore</param-name>
<param-value>/mykeystore</param-value>
</init-param>
<init-param>
<param-name>KeyStoreType</param-name>
<param-value>jks</param-value>
</init-param>
<init-param>
<param-name>PrivateKeyAlias</param-name>
<param-value>passalias</param-value>
</init-param>
<init-param>
<param-name>KeyStorePasswordProperties</param-name>
<param-value>mykeystore.properties</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>HttpClusterServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HttpClusterServlet</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HttpClusterServlet</servlet-name>
<url-pattern>*.jspx</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HttpClusterServlet</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HttpClusterServlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
weblogic.xml
<!DOCTYPE weblogic-web-app PUBLIC
"-//BEA Systems, Inc.//DTD Web Application 9.1//EN"
"http://www.bea.com/servers/wls810/dtd/weblogic
810-web-jar.dtd">
<weblogic-web-app>
</weblogic-web-app>
When ManagedServer1
is in not running or down, the request will go to the other servers which is
active and running with the requested state without any loss of data. The
Managerserver mapping will be taken care by the algorithm you chose when you
are creating the Cluster. In my case its round-robin.
Failover flow diagram- ManagedServer 1 is in Shutdown state
Now deploy the web application HTTPProxy plugin into
weblogic Admin server (not on cluster).
After deployment, you can access the deployed adf
application via admin port. Given below my local sample url for reference
Failover
demonstration (Demo app download here)
Look at the below screen, Its Running on Adf_Server-1. Server
Name is shown in simple outPutText with weblogic.Name property
JSFUtils.setExpressionValue("#{pageFlowScope.serverName}",
System.getProperty("weblogic.Name"));
<af:panelLabelAndMessage
label="Running on :: " id="plam4"
inlineStyle="color:Blue; font-size:medium;">
<af:outputText value="#{pageFlowScope.serverName}"
id="ot4"/>
</af:panelLabelAndMessage>
Note: Fields also binded with Richcomponent and values with scopes
<af:inputText label="Name" id="it1"
value="#{pageFlowScope.name}"
binding="#{pageFlowScope.clustertestbean.nameRichTxt}"/>
<af:inputText
label="Department" id="it2" value="#{pageFlowScope.department}"/>
<af:inputText label="Location"
id="it3" value="#{backingBeanScope.location}"/>
Now stopping my managed server Adf_Server-1 and click
Next button
Adf_Server-1 is in SHUTDOWN state, and Keeping the same page
same session clicking Next button,
Now it’s showing the server name as Adf_Server-2 which is in
running state. Also all the values in the form from Main page carried to
Details page as well.
Here we can understand that when the one server is down
i.e., when failover happens cluster automatically manages state and keeps the
application stable without any service interruption.Your application will be Highly available always.
Downloads
Leave your comments below if any issues. Thanks