Session Replication in Wildfly 10
Pre-Requisites:
-
If using domain mode, the slave node should belong to the group of full-ha profiles and the master should be configured with the ha or full-ha profile.
-
Ensure all nodes can communicate with each other in the network
-
All session attributes must be Serialized
If using domain mode, the slave node should belong to the group of full-ha profiles and the master should be configured with the ha or full-ha profile.
Ensure all nodes can communicate with each other in the network
All session attributes must be Serialized
Session replication can be done in two ways Distributed which are by default limited to two nodes and the other is Replication.
DISTRIBUTED CACHING
To enable Session Replication need to perform below changes
-
In the web application , Add <distributable /> tag in web.xml (this will enable Web session clustering)
-
Open domain.xml (located at {Wildfly-Home/domain/configuration/})
3. Search below tag
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
4. Change cluster password in domain.xml
<cluster password="${jboss.messaging.cluster.password:CHANGE ME!!}"/>
Search CHANGE ME!! and replace it with an appropriate password.
E.g.
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
<server name="default">
<cluster password="${jboss.messaging.cluster.password:A123456.}"/>
........................
In the web application , Add <distributable /> tag in web.xml (this will enable Web session clustering)
Open domain.xml (located at {Wildfly-Home/domain/configuration/})
3. Search below tag
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
4. Change cluster password in domain.xml
<cluster password="${jboss.messaging.cluster.password:CHANGE ME!!}"/>
3. Search below tag
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
4. Change cluster password in domain.xml
<cluster password="${jboss.messaging.cluster.password:CHANGE ME!!}"/>
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
........................
</server>
</subsystem>
Note :
-
All the objects set in the HttpSession should be Serialized for Session Replication
-
Session Replication is done by default to only 2 nodes and it is distributed caching
-
To replicate it to all nodes need to change it to a replicated cache
All the objects set in the HttpSession should be Serialized for Session Replication
Session Replication is done by default to only 2 nodes and it is distributed caching
To replicate it to all nodes need to change it to a replicated cache
REPLICATED CACHING
To enable replicated caching to all nodes in the cluster
1. Open domain.xml (Path : Wildfly-home/domain/configuration)
Now search for below tag
<subsystem xmlns="urn:jboss:domain:infinispan:4.0">
2. Replace below tag
1. Open domain.xml (Path : Wildfly-home/domain/configuration)
Now search for below tag
<cache-container name="web" default-cache="dist" module="org.wildfly.clustering.web.infinispan">
<transport lock-timeout="60000" />
<distributed-cache name="dist" mode="ASYNC" l1-lifespan="0" owners="2">
<locking isolation="REPEATABLE_READ" />
<transaction mode="BATCH" />
<file-store />
</distributed-cache>
<distributed-cache name="concurrent" mode="SYNC" l1-lifespan="0" owners="2">
<file-store />
</distributed-cache>
</cache-container>
With
<cache-container name="web" default-cache="repl" module="org.wildfly.clustering.web.infinispan">
<transport lock-timeout="60000" />
<replicated-cache name="repl" mode="ASYNC">
<transaction locking="OPTIMISTIC" />
<transaction mode="BATCH" />
<locking isolation="READ_COMMITTED" />
<file-store />
</replicated-cache>
</cache-container>
Comments
Post a Comment