Results 1 to 7 of 7

Thread: subflows within a transaction

  1. #1
    Join Date
    Apr 2005
    Location
    Edinburgh
    Posts
    18

    Default subflows within a transaction

    Within a transaction in the main flow, should the _txToken be passed to subflows? This doesn't appear to be happening in my application. The _txToken is always null in each of the subflow states.

    Daniel

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Yes this is a limitation of the default TransactionSynchronizer implementation, as it manages the token in local flowScope. You'll likely need a custom implementation to manage the token somewhere else, like in a database... we want to provide more out of the box help impls ourselves, so any jumpstart here if you're on a short timeline would be much appreciated.
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    A bit more info on what you need to do to plug in a custom transaction manager:

    1. First you need to implement your custom transaction manager by implementing the interface org.springframework.web.flow.execution.Transaction Synchronizer. I.e. your implementation could store the transaction token in a database.

    2. Next, register your custom transaction manager with the flow execution manager of your flow controller. Something like this:

    Code:
    <bean id="myFlowController" name="/myFlow.htm" class="org.springframework.web.flow.mvc.FlowController">
       <property name="flowExecutionManager">
          <bean class="org.springframework.web.flow.execution.servlet.ServletFlowExecutionManager">
             <property name="transactionSynchronizer">
                <bean class="my.custom.TxSynchronizer"/>
             </property>
          </bean>
       </property>
    </bean>
    Erwin

  4. #4
    Join Date
    Apr 2005
    Location
    Edinburgh
    Posts
    18

    Default

    Couldn't the transaction ID be passed into the subflow in the same way as other parameters?

  5. #5
    Join Date
    Apr 2005
    Location
    Edinburgh
    Posts
    18

    Default

    After providing a custom TransactionSynchronizer which uses a different storage mechanism for storing the token, the token is still null in subflow states. However, completing the subflow, by reaching an end state, returns to the main flow and allows normal execution. If in the subflow and the browser back button is pressed, returning to a view state of the main flow, results in any further action to throw the following exception:
    Code:
    java.lang.NullPointerException
    	at org.springframework.web.flow.Flow.getTransitionableState&#40;Flow.java&#58;307&#41;
    	at org.springframework.web.flow.Flow.getRequiredTransitionableState&#40;Flow.java&#58;324&#41;
    	at org.springframework.web.flow.execution.impl.FlowExecutionImpl.signalEvent&#40;FlowExecutionImpl.java&#58;303&#41;
    	at org.springframework.web.flow.execution.FlowExecutionManager.onEvent&#40;FlowExecutionManager.java&#58;289&#41;
    	at org.springframework.web.flow.struts.FlowAction.doExecuteAction&#40;FlowAction.java&#58;142&#41;
    Any suggestions on this one?

  6. #6
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    The NPE was a bug: the sytem should've thrown a NoSuchFlowStateException then - I've corrected this.

    Not sure why your transaction synchroinizer token would be null if you're keying the token in storage based on the flowExecutionId... (as it stays the same regardless of how many subflows spawn)
    Keith Donald
    Core Spring Development Team

  7. #7
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    danielm,

    As you suggest, you could also map the token into the subflow flow scope. That way you can use the out-of-the-box TokenTransactionSynchronizer.

    Erwin

Similar Threads

  1. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  2. Replies: 0
    Last Post: Jun 6th, 2005, 06:22 AM
  3. Replies: 3
    Last Post: May 16th, 2005, 07:04 AM
  4. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  5. Transaction pb Hibernate/MySQL
    By syluser in forum Data
    Replies: 2
    Last Post: Aug 28th, 2004, 02:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •