I have 3 servers:
- 2 Jboss 7.1.1 Server
- 1 Apache server
I am using mod_jk
And my configuration follow below structure:
In my web application, I have a session counter.
Client 1 request to Web Server (I mean Load Balancer Server), Web Server choose the first JBoss AS.
This time, Counter++ (Example: Counter = 5).
After that, I shutdown the first JBoss AS.
And then, client continue send request to Web Server, the first JBoss AS goes down, so Web Server will choose the second JBoss AS.
This time Counter start again (Counter = 0)
So. I want to keep session counter in every JBoss AS.
I mean, this time, Counter should be 6 after the first JBoss AS goes down.
How can I do?
Refer to below configuration.
#/etc/apache2/workers.properties
##### Balancer ######
#worker.jboss.type=lb
#worker.jboss.balance_workers=jboss1,jboss2
#worker.jkstatus.type=status
worker.list=jboss,jk-status
##### JBOSS Machine 1 #####
worker.jboss1.type=ajp13
worker.jboss1.host=192.168.20.131
worker.jboss1.port=8009
worker.jboss1.lbfactor=1
##### JBOSS Machine 2 #####
worker.jboss2.type=ajp13
worker.jboss2.host=192.168.20.130
worker.jboss2.port=8009
worker.jboss2.lbfactor=1
##### LOAD Balancing ######
worker.jboss.type=lb
worker.jboss.balance_workers=jboss1,jboss2
worker.jboss.sticky_session=true ## I used to sticky session
worker.jk-status.type=status
My JBoss Web Application:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>/</context-root>
<replication-config>
<replication-trigger>SET_AND_GET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
</replication-config>
</jboss-web>
My Web Configuration
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>HelloWorld</display-name>
<distributable/>
</web-app>
My Standalone.xml
<system-properties>
<property name="jvmRoute" value="jboss1"/>
<property name="useJK" value="true"/>
</system-properties>
AJP Connector
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" instance-id="jboss1" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<connector name="ajp" protocol="AJP/1.3" scheme="ajp" socket-binding="ajp" />
<virtual-server name="default-host" enable-welcome-root="false">
<alias name="localhost"/>
<alias name="example.com"/>
</virtual-server>
</subsystem>