Announcement Announcement Module
Collapse
No announcement yet.
subflows within a transaction Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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

      Comment


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

        Comment


        • #5
          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?

          Comment


          • #6
            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)

            Comment


            • #7
              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

              Comment

              Working...
              X