2 Replies Latest reply on Dec 23, 2018 2:05 PM by srpaluri

    Session replication using Database persistence in Jboss 7.0.7

    srpaluri

      We have a HA cluster configured using Apache as Webserver and Jboss EAP 7.0.7 as the Application server. cluster has 2 nodes. Database is Oracle 12c

      We configured Data source and WEB cache-container in standalone-full-ha.xml as below.

       

      1.                <datasource jndi-name="java:/jbsessionds" pool-name="jbsessionds" enabled="true">

                          <connection-url>jdbc:oracle:thin:@HOST:PORT/SID</connection-url>

                          <driver>oracle</driver>

                          <pool>

                              <min-pool-size>5</min-pool-size>

                              <max-pool-size>500</max-pool-size>

                          </pool>

                          <security>

                                  <user-name>jbsession</user-name>

                                  <password>jbsession</password>

                          </security>

                      </datasource>

       

                          <driver name="oracle" module="DBDRIVER">

                              <xa-datasource-class>oracle.jdbc.driver.OracleDriver</xa-datasource-class>

                          </driver>

       

      2. User jbsession created in Database as below:

      CREATE USER jbsession IDENTIFIED BY jbsession;

      GRANT CONNECT TO jbsession;

      GRANT CONNECT, RESOURCE, DBA TO jbsession;

      GRANT CREATE SESSION TO jbsession with admin OPTION;

       

      3.            <cache-container name="web" default-cache="database" module="org.jboss.as.clustering.web.infinispan">

                      <transport lock-timeout="60000"/>

                      <local-cache name="database">

                          <binary-keyed-jdbc-store data-source="jbsessionds" dialect="ORACLE" purge="false" shared="true" singleton="false">

                              <binary-keyed-table prefix="JBSESSION">

                                  <id-column name="id" type="VARCHAR2(500)"/>

                                  <data-column name="datum" type="BLOB"/>

                                  <timestamp-column name="version" type="NUMBER"/>

                              </binary-keyed-table>

                          </binary-keyed-jdbc-store>

                      </local-cache>

                  </cache-container>

       

      After restarting the Jboss server, there were no errors observed in the server.log related to the above changes. Tables were created in Database for the applications installed in our Application server as follows:

       

      JBSESSION_Application1_war

      JBSESSION_Application2_war

      and so on..

       

      and could see some sessions for user JBSESSION in GV$sessions table.

       

      But when i login to my application and create sessions, i do not see any entries in any of the tables mentioned above and when i try to validate the session replication scenario, by stopping the Jboss node in which the session is created, fail over is not happening. (since session data is not getting persisted)

       

      I believe i'm missing some thing in terms of Data source or the cache-container configuration or both. With distributed mode we are able to achieve session replication, so i doubt there is anything missing from application perspective.

       

      Appreciate any inputs in this regard.

        • 1. Re: Session replication using Database persistence in Jboss 7.0.7
          pferraro

          A couple of notes:

          1. Using a local-cache in cluster leaves your application is vulnerable to stale reads.  With a shared store, you want to use an invalidation-cache instead.  This ensures that nodes never retain stale data in memory.
          2. In EAP/WildFly, cache stores use passivation mode by default.  This means that cache entries only persist to the cache store during shutdown, or when the number of session exceeds the configured value for max-active-sessions (configured via jboss-web.xml).  When using a non-replicating cache, passivation mode leaves your application vulnerable to data loss if a node crashes.  You'll instead want to configure your cache store using passivation="false".
          1 of 1 people found this helpful
          • 2. Re: Session replication using Database persistence in Jboss 7.0.7
            srpaluri

            Thanks Paul.

             

            with invalidation-cache it is working as expected.