Using JDG as External Cache Container for WildFly HTTP Session Replication: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 42: Line 42:


<pre>
<pre>
<cache-container name="web" aliases="standard-session-cache" default-cache="repl" module="org.jboss.as.clustering.web.infinispan">
        <subsystem xmlns="urn:jboss:domain:infinispan:1.5">
    <transport lock-timeout="60000"/>
            <cache-container name="web" aliases="standard-session-cache" default-cache="repl" module="org.jboss.as.clustering.web.infinispan">
    <replicated-cache name="repl" mode="SYNC" batching="true">
                <transport lock-timeout="60000"/>
        <remote-store cache="jdg-http-sessions" socket-timeout="60000" tcp-no-delay="true" shared="true" preload="true" passivation="false" fetch-state="false" purge="false">
                <replicated-cache name="repl" mode="ASYNC" batching="true">
            <remote-server outbound-socket-binding="initial-jdg-server"/>
                    <remote-store cache="jdg-http-sessions" socket-timeout="60000" tcp-no-delay="true" shared="true" preload="true" passivation="false" fetch-state="false" purge="false">
        </remote-store>
                        <remote-server outbound-socket-binding="initial-jdg-server"/>
    </replicated-cache>
                    </remote-store>
</cache-container>
                </replicated-cache>
            </cache-container>
        </subsystem>
</pre>
</pre>



Revision as of 02:36, 1 June 2016

External

Internal

Relevance

  • EAP 6.5, JDG 6.6

Overview

JDG can be used as an external cache container for HTTP session data within WildFly. This allows scaling of the data layer independent of the application, and enables different WildFly clusters, that may reside in various domains, to access data from the same JDG cluster.

Setup the JDG Cluster

Configuration details are available here: Infinispan Configuration. The external JDG cluster will be accessed by the WildFly instance over the HotRod protocol.

Define a dedicated cache for each web application In this specific case, the dedicated cache name is "jdg-http-sessions":

<subsystem xmlns="urn:infinispan:server:core:6.4">
  <cache-container name="clustered" default-cache="default" statistics="true">
    <transport executor="infinispan-transport" lock-timeout="60000"/>
    <distributed-cache name="default" ...>
      ...
    </distributed-cache>
    <distributed-cache name="jdg-http-sessions" owners="2" mode="SYNC" start="EAGER"/>
  </cache-container>
  ...
</subsystem>

Configure the WildFly Cache

For each distributable application, an entirely new WildFly cache must be created.

The first one can be created reconfiguring the existing 'web cache container. All other cache containers/caches can be removed.

        <subsystem xmlns="urn:jboss:domain:infinispan:1.5">
            <cache-container name="web" aliases="standard-session-cache" default-cache="repl" module="org.jboss.as.clustering.web.infinispan">
                <transport lock-timeout="60000"/>
                <replicated-cache name="repl" mode="ASYNC" batching="true">
                    <remote-store cache="jdg-http-sessions" socket-timeout="60000" tcp-no-delay="true" shared="true" preload="true" passivation="false" fetch-state="false" purge="false">
                        <remote-server outbound-socket-binding="initial-jdg-server"/>
                    </remote-store>
                </replicated-cache>
            </cache-container>
        </subsystem>

Declare the Outbound Socket

    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        ...
        <outbound-socket-binding name="initial-jdg-server">
            <remote-destination host="localhost" port="11222"/>
        </outbound-socket-binding>
    </socket-binding-group>

Configura the Application to be Distributable

web.xml, jboss-web.xml.