7 Replies Latest reply on Dec 17, 2007 4:45 AM by kukeltje

    how to merge global variables value in a JOIN

    tsandor

      Hi,
      I've seen the pattern "WPF3: Synchronization" and checked the test case "Wfp03SynchronizationTest" in jBPM3.1.4.

      However, this workflow situtation is pretty straight forward, I cannot image how to extend it when there's also data with the workflow.

      E.g. let's see the jpdl in the testcase:

      <process-definition>
       <start-state name='start'>
       <transition to='fork' />
       </start-state>
       <fork name='fork'>
       <transition name='first' to='one' />
       <transition name='second' to='two' />
       </fork>
       <state name='one'>
       <transition to='join' />
       </state>
       <state name='two'>
       <transition to='join' />
       </state>
       <join name='join'>
       <transition to='end' />
       </join>
       <end-state name='end' />
      </process-definition>
      


      What if I have a String context variable named "str" with value "start" in start-state, and modify it in "state one" and "state two", str="one" and str="two" respectively.

      What will be the value at the end after the join?

      Will the "fork" make replicas of context variables when doing the fork, so that global values will not be overloaded in "state one" nor in "state two" in the same time? I guess, making replicas is necessary, because a variable modified in "state one" cannot be seen in "state two", since the later may also modify (and thus it would overload) the value of same variable.
      If so, how will "join" merge these variable replicas? What will be the final context variable value?

      Thanks for your help.
      --
      Thomas




        • 1. Re: how to merge global variables value in a JOIN
          kukeltje

          afaik, states do not have 'local' variables, so once you update it in state one, state two also has access to them. Only when using tasks you get automatic local copies of the values from the time the task is created. Each task completed updates the global variable, so the last task completed is the one that 'wins'. A fork and join do not influence this at all

          • 2. Re: how to merge global variables value in a JOIN
            tsandor

            Hi Ronald,

            "kukeltje" wrote:
            Each task completed updates the global variable, so the last task completed is the one that 'wins'.


            This means there will be a data-loss. E.g. A modifies its local replica of a global context variable, and B modifies also its replica. But if B approves later, modifications of A will be lost, only B's local replica will be stored back globally.

            Am I right?

            • 3. Re: how to merge global variables value in a JOIN
              kukeltje

              Correct, and whether it is dataloss is debatable (the behaviour is by design). The data A modified is still present in that finished task.

              If you want/prefere other behaviour, you can discuss that in the design forum, but keep in mind... it is a real complex issue that often has it's roots in an not well designed process. Meaning, if you can prevent parallel tasks modifying the same date you should

              • 4. Re: how to merge global variables value in a JOIN
                sirajm

                 

                "kukeltje" wrote:
                Correct, and whether it is dataloss is debatable (the behaviour is by design). The data A modified is still present in that finished task.


                Hi Ronald,

                I am also doing some research on process context variable so I would like to know how to read the value modified by 'A' in the finished task.

                Thanks,
                Siraj

                • 5. Re: how to merge global variables value in a JOIN
                  kukeltje

                  use the api to get a list of all tasks of that user. Finished tasks are also in there. Not sure if you can retrieve jsut tasks for this processinstance. I think you can. Then you have access to the variables. Play a little with the api and learn it....

                  • 6. Re: how to merge global variables value in a JOIN
                    stanatbics

                    Hi

                    Is it possible to have different value with the same name for two instances..

                    Any configuration need to be modified?

                    Regards
                    Stan

                    • 7. Re: how to merge global variables value in a JOIN
                      kukeltje

                      two instances of what? processes? ofcourse....