Este contenido no está disponible en el idioma seleccionado.

Chapter 38. Externalize Sessions


38.1. Externalize HTTP Session from JBoss EAP to JBoss Data Grid

Red Hat JBoss Data Grid can be used as an external cache container for application specific data in JBoss Enterprise Application Platform (EAP), such as HTTP Sessions. This allows scaling of the data layer independent of the application, and enables different EAP clusters, that may reside in various domains, to access data from the same JBoss Data Grid cluster. Additionally, other applications can interface with the caches presented by Red Hat JBoss Data Grid.

Note

The following procedures have been tested and confirmed to function on JBoss EAP 7.0 and JBoss Data Grid 7.0; when externalizing HTTP sessions with JBoss Data Grid 7.x only use these, or later, versions of each product.
The below procedure applies for both standalone and domain mode of EAP; however, in domain mode each server group requires a unique remote cache configured. While multiple server groups can utilize the same Red Hat JBoss Data Grid cluster the respective remote caches will be unique to the EAP server group.

Note

For each distributable application, an entirely new cache must be created. It can be created in an existing cache container, for example, web.

Procedure 38.1. Externalize HTTP Sessions

  1. Ensure the remote cache containers are defined in EAP's infinispan subsystem; in the example below the cache attribute in the remote-store element defines the cache name on the remote JBoss Data Grid server:
    <subsystem xmlns="urn:jboss:domain:infinispan:4.0">
      [...]
      <cache-container name="web" default-cache="dist" module="org.jboss.as.clustering.web.infinispan" statistics-enabled="true">
        <transport lock-timeout="60000"/>
        <invalidation-cache name="jdg" mode="SYNC">
          <locking isolation="REPEATABLE_READ"/>
          <transaction mode="BATCH"/>
          <remote-store remote-servers="remote-jdg-server1 remote-jdg-server2" 
                        cache="default" socket-timeout="60000" 
                        preload="true" passivation="false" purge="false" shared="true"/>
        </replicated-cache>
      </cache-container>
    </subsystem>
  2. Define the location of the remote Red Hat JBoss Data Grid server by adding the networking information to the socket-binding-group:
    <socket-binding-group ...>
      <outbound-socket-binding name="remote-jdg-server1">
        <remote-destination host="JDGHostName1" port="11222"/>
      </outbound-socket-binding>
      <outbound-socket-binding name="remote-jdg-server2">
        <remote-destination host="JDGHostName2" port="11222"/>
      </outbound-socket-binding>
    </socket-binding-group>
  3. Repeat the above steps for each cache-container and each Red Hat JBoss Data Grid server. Each server defined must have a separate <outbound-socket-binding> element defined.
  4. Add passivation and cache information into the application's jboss-web.xml. In the following example web is the name of the cache container, and jdg is the name of the default cache located in this container. An example file is shown below:
    <?xml version="1.0" encoding="UTF-8"?>
    <jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_10_0.xsd"
               version="10.0">
     
        <replication-config>
            <replication-granularity>SESSION</replication-granularity>
            <cache-name>web.jdg</cache-name>
        </replication-config>
        
    </jboss-web>

    Note

    The passivation timeouts above are provided assuming that a typical session is abandoned within 15 minutes and uses the default HTTP session timeout in JBoss EAP of 30 minutes. These values may need to be adjusted based on each application's workload.
Red Hat logoGithubRedditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

© 2024 Red Hat, Inc.