2 Replies Latest reply on Aug 8, 2007 1:46 PM by Ronald van Kuijk

    Lifecycle of process and task instances

    Hugo Herrmann Newbie

      Hello everybody!

      I wonder about the lifecycle of process instances, subprocess instances and task instances and how they are related to each other.

      For the process instances I identified four states: started ? suspended ? ended

      -> A process instance is started as soon it is in the database
      -> If a process instance is suspended, no tasks can be done and it can?t be signalled. What is with timers in suspended state. Do they continue or are they suspended as well?
      -> Ended means a process instance completed normally

      This should be the same for subprocesses instances as they are normal process instances at first.

      For task instances the documentation (chapter 11.2.1) describes three states: created ? started ? ended.
      But in fact there seem to be more states: suspended ? cancelled ? open.

      -> Created should be clear, this is as soon as an entry in the taskinstance table in the database is made.
      -> What means the started state? Who or what is supposed to start a task instance when? Only the actor?
      -> Suspended is like process instance suspension but just for the single task. Isn?t it?
      -> Ended is the task instance is ended normally (the taskinstance end date in the database is not null)
      -> Cancelled is the task was cancelled (the taskinstance end date is not null AND the iscanceled flag is set in the database)
      -> What is the open state for? (the isopen flag is set in the database)


      Now: How do states of process instance, subprocess instance and task instances of the process instance and any subprocess instance relate?

      What do I mean? For example:
      ->When ending a process instance, are all subprocess instances and task instances of the process and subprocess instances ended as well?
      ->Does a suspended process instance mean that also all subprocess instances of that process instance are suspended and all tasks of the process and subprocess instances as well?

      So as you see I still didn?t get the whole picture yet, despite digging into the documentation and source code and searching the forum (yes, I found some hints but some have been contradictory, though). Therefore I would really appreciate one of you, maybe even one of the developers, giving me this picture. Probably I am also not the only one seeking for it.

      Thanks in advance,
      Markus

        • 1. Re: Lifecycle of process and task instances
          Hugo Herrmann Newbie

          Hello again!

          Isn't there anybody who can explain me how the lifecycles or process instances, subprocess instances and task instances look like and how these lifecycles relate to each other?

          Thanks again,
          Markus

          • 2. Re: Lifecycle of process and task instances
            Ronald van Kuijk Master

             

            So as you see I still didn?t get the whole picture yet, despite digging into the documentation and source code and searching the forum (yes, I found some hints but some have been contradictory, though). Therefore I would really appreciate one of you, maybe even one of the developers, giving me this picture.

            Yes, sometimes the docs are 'out of date'. The sourcecode is always best

            Probably I am also not the only one seeking for it.

            Well, have not had lots of questions like this, none in fact. So....

            Isn't there anybody who can explain me how the lifecycles or process instances, subprocess instances and task instances look like and how these lifecycles relate to each other?


            There probably are lost, but most do not take the time (including me at first) since it is a long post with a lot of questions... AND the source provides some answers...

            Let's go:

            What is with timers in suspended state. Do they continue or are they suspended as well?

            If you look at the testcases of tasks and timers, you see there is nothing there regarding this question. Although timers (jobs) have a 'isSuspended()' method, it is never used in the code... Some simple research.... There are also no open issues in the JIRA, so at best it is undefined. Write some testclasses (extend TaskInstanceDBTest) to see the behaviour

            -> Suspended is like process instance suspension but just for the single task. Isn?t it?
            Could be, I doubt however it was ever the intention to suspend individual tasks

            Now looking at the processInstance.suspend(), jobs (including timers on tasks) ARE suspended if you suspend the process!!! This strengthens my previous remark on suspending individual tasks (Again.... all from looking at the code)

            -> What is the open state for? (the isopen flag is set in the database)

            Look in the source when it is set... it is sort of a convenience attribute....

            Now: How do states of process instance, subprocess instance and task instances of the process instance and any subprocess instance relate?


            Tokens, tokens, tokens... the key concept of jBPM. They are parsed recusively when things are ended, cancelled, suspended or resumed as can be seen in the source...