It is a set of classes aiming to improve Spring Web Flow's behavior for Optimized Session Replication.
- Supports Spring Web Flow 2.4.x
- An implementation of Conversation Manager for Spring Web Flow (SWF) with the purpose of improving session replication that use fine granularity.
- Id generation utility, designed to generate ids for uniquely identifying. It includes a couple of generator strategies.
Conversation Manager manages conversations and effectively controls how state
is stored physically when a flow execution is paused.
SWF provides a default ConversationManager
implementation: the
SessionBindingConversationManager
, which simply manages conversational state
in the HttpSession storing all of the webflow conversations in the same
attribute. For application servers who do session replication on changes in
and per attribute of the session map, like Jboss AS, this cause that all of
the conversations's data get replicated even though just one conversation is
altered.
This solution provides an option for Conversation Manager to stores each
conversation in it's own slot in the session map, thereby limiting replication
to the conversation that are executed:
ReplicationOptimizedSessionBindingConversationManager
. It supports the same
configuration facilities that SessionBindingConversationManager
,
- max-conversations. The maximum number of active conversations allowed in a session
- lock-timeout. Time period that can elapse before a timeout occurs on an attempt to acquire a conversation lock
- session-key. The key this conversation manager uses to store common conversations's data in the session and as prefix of the session-key for each individual conversation.
And it also allows to set a custom id generator strategy for generating ids
for uniquely identifying the conversations managed through property
conversationIdGenerator
(see Extended usages).
Clone the Git repository first and switch to the created directory:
$ git clone https://github.com/gfernandez598/springwebflow-optforrepl.git
You can install binaries only or includes sources and javadoc too:
$ mvn install
$ mvn install -Pgenerate-sources-and-javadocs
Add dependency to the project
<dependency>
<groupId>com.github.gfernandez598</groupId>
<artifactId>springwebflow-optforrepl</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
Configure SWF: define custom conversation manager and set it to the Flow Execution Repository.
<bean id="replicationConversationManager" class="com.github.gfernandez598.swf.conversation.optforrepl.ReplicationOptimizedSessionBindingConversationManager" />
<flow-executor id="flowExecutor">
<flow-execution-repository conversation-manager="replicationConversationManager" />
</flow-executor>
The solution provides conversation Id generators RandomUUIDUidGenerator
(default) and SequenceUidGenerator
, but can choose any other. Custom
generators must implements the UidGenerator
interface. Continuing the
example, can be set it:
<bean id="prettyConversationIdGenerator" class="com.github.gfernandez598.swf.util.SequenceUidGenerator" />
<bean id="replicationConversationManager" class="com.github.gfernandez598.swf.conversation.optforrepl.ReplicationOptimizedSessionBindingConversationManager">
<property name="conversationIdGenerator" ref="prettyConversationIdGenerator" />
</bean>
- Spring Web Flow 2.4.x
- Jboss AS 7.1.1.Final (will not appreciate improvement because of this AS7-4743)
- Jboss AS 7.1.3.Final
Take a look at springwebflow-optforrepl-samples.
The implementation of ReplicationOptimizedSessionBindingConversationManager
use
org.springframework.webflow.conversation.impl.JdkConcurrentConversationLock
class which is not public for previous versions.
This implementation is based on the workaround created by Jon Osborn (see SWF-1030)
The project is licensed under the Apache License, Version 2.0.