danny.lesnik
danny.lesnik

Reputation: 18639

Tomcat Session Replication + Spring bean

I have a Spring bean which will be used for storing user details or any other relevant information. I store this bean on the session level.

<bean id="userSession" class="com.test.SessionImpl" scope="session">
<aop:scoped-proxy/>
</bean> 

Now I have few server and I would like to build Cluster with session replication using SimpleTcpCluster.

When I'm updating the bean on one of the cluster node will it be replicated to other nodes? I have a concern regarding that because this bean resides on sesison level, but not in the session itself. Correct me if I'm wrong.

Upvotes: 1

Views: 2339

Answers (1)

sourcedelica
sourcedelica

Reputation: 24047

As long as Tomcat can replicate the object (ie, the object is serializable) then the bean will be replicated. It is stored as an attribute on the session -- you can verify this either in your debugger or by iterating over the attributes of the session in your code.

The spring docs (http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-factory-scopes-session) imply this is the case but are not explicit about the exact mechanics.

Upvotes: 2

Related Questions