Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can configure your container to persist session to database using JDBC. If you use tomcat you can configure JDBC session persistence provider. I assume you can do similar thing on other containers too.</p> <p>I've documented the steps on setting up tomcat JDBC session persistence on my blog: <a href="http://gerrydevstory.com/2013/08/21/tomcat-7-jdbc-session-persistence/">http://gerrydevstory.com/2013/08/21/tomcat-7-jdbc-session-persistence/</a></p> <p>In summary you need a configuration like this on your context.xml:</p> <pre><code>&lt;Manager className="org.apache.catalina.session.PersistentManager" maxIdleBackup="10"&gt; &lt;Store className="org.apache.catalina.session.JDBCStore" connectionURL="jdbc:mysql://localhost/mytomcat?user=root" driverName="com.mysql.jdbc.Driver" sessionAppCol="app_name" sessionDataCol="session_data" sessionIdCol="session_id" sessionLastAccessedCol="last_access" sessionMaxInactiveCol="max_inactive" sessionTable="tomcat_sessions" sessionValidCol="valid_session" /&gt; &lt;/Manager&gt; </code></pre> <p>However, <code>maxIdleBackup="10"</code> above indicates session will be flushed into jdbc only after 10 seconds of inactivity. I don't know if setting it to 0 will work.</p> <p>I imagine getting whole thing to work will be hard without sticky load balancer session, eg: how do you ensure session updates are flushed before the next request? You can't guarantee the next request will be served by the same node.</p> <p>Maybe another alternative is if you can hack your self / there's another session provider library out there that writes straight into database.</p> <p><em>Edit 21 May 2014:</em></p> <p>I just figured out <a href="http://gerrydevstory.com/2014/05/15/java-web-session-clustering-with-hazelcast/">hazelcast WM is a great library to do peer-to-peer session replication</a>. All you need to do is include hazelcast jars to the classpath, setup hazelcast-wm as filter on your web.xml and configure hazelcast. It will automatically replicate session objects accross clusters.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload