8 Replies Latest reply on Mar 5, 2008 9:59 AM by kukeltje

    Strange behaviour when using fork

    bungrudi

      Hello,

      I have a flow that basically does the following:
      AO -> RO#1 -> ... -> HBS -> REV_ADM -> REV#1 -> ... -> REV#3 ->
      -> COM_ADM -> COM#1 -> ... ->COM#3 ->

      (continued)
      join1 -> dropped

      on each node, it should be checked whether any user is currently assigned to it. if yes, create a task and assign. if not, continue execution.
      my idea to this is to make each task-node "create-task=false", assign an "enter-node" handler that checks whether any user is assigned to the node, and then create task/continue execution.
      This solution works fine when the execution path is straightforward (no forking and async execution involved).
      but when "fork" come into play, the behaviour is far from what i expected.

      the debug print (from my own code, to simplify the printout) is like the following:

      http://www.2shared.com/file/2939237/171d5892/stdout_jbpm.html


      as you can see after HBS node it hits the fork node, and it started to execute in a way beyond my comprehension.
      yet more strange behaviour is that when the execution is stopped in HBS for a while (created a task and waited for the task to be completed), the printout is far shorter, but still far from what i expected and still beyond my comprehension:

      Token(/)264445391 calc auth level
      Token(/)264445391 review RO #1
      Token(/)264445391 review RO #2
      Token(/)264445391 review SRM
      Token(/)264445391 review GAM
      Token(/)264445391 review BM
      Token(/)264445391 review HOBS
      Token(/)264445391 review HA
      Token(/)264445391 review HR
      Token(/)264445391 review HBS
      Token(/to.pick compliances)264625293 pick compliances
      Token(/to.pick compliances)264625293 compliance #1
      Token(/to.pick compliances)264625293 compliance #2
      Token(/to.pick compliances)264625293 compliance #3
      Token(/to.pick compliances)264625293 compliance #3
      Token(/to.pick compliances)264625293 compliance #2
      Token(/to.pick compliances)264625293 compliance #3
      Token(/to.pick compliances)264625293 compliance #3
      Token(/to.pick compliances)264625293 compliance #1
      Token(/to.pick compliances)264625293 compliance #2
      Token(/to.pick compliances)264625293 compliance #3
      Token(/to.pick compliances)264625293 compliance #3
      Token(/to.pick compliances)264625293 compliance #2
      Token(/to.pick compliances)264625293 compliance #3
      Token(/to.pick compliances)264625293 compliance #3
      Token(/to.pick reviewer)264625334 pick reviewer
      Token(/to.pick reviewer)264625334 reviewer #1
      Token(/to.pick reviewer)264625334 reviewer #2
      Token(/to.pick reviewer)264625334 reviewer #3
      Token(/to.pick reviewer)264625334 reviewer #3
      Token(/to.pick reviewer)264625334 reviewer #2
      Token(/to.pick reviewer)264625334 reviewer #3
      Token(/to.pick reviewer)264625334 reviewer #3
      Token(/to.pick reviewer)264625334 reviewer #1
      Token(/to.pick reviewer)264625334 reviewer #2
      Token(/to.pick reviewer)264625334 reviewer #3
      Token(/to.pick reviewer)264625334 reviewer #3
      Token(/to.pick reviewer)264625334 reviewer #2
      Token(/to.pick reviewer)264625334 reviewer #3
      Token(/to.pick reviewer)264625334 reviewer #3
      


      i'm expecting that after "review HBS", it should be like

      Token(/to.pick compliances)264625293 pick compliances
      Token(/to.pick compliances)264625293 compliance #1
      Token(/to.pick compliances)264625293 compliance #2
      Token(/to.pick compliances)264625293 compliance #3
      Token(/to.pick reviewer)264625334 pick reviewer
      Token(/to.pick reviewer)264625334 reviewer #1
      Token(/to.pick reviewer)264625334 reviewer #2
      Token(/to.pick reviewer)264625334 reviewer #3

      and then join and finish.

      did i do something wrong? is ctx.getNode().leave(ctx) is the wrong way to continue execution? or continuing execution from inside an action handler is not a supported way at all?

      the unit test can be downloaded from

      http://www.2shared.com/file/2939148/caa56d9d/fork_test.html

      anyone has any insight???

      regards,

      rudi

        • 1. Re: Strange behaviour when using fork
          bungrudi

           

          "bungrudi" wrote:


          I have a flow that basically does the following:
          AO -> RO#1 -> ... -> HBS -> REV_ADM -> REV#1 -> ... -> REV#3 ->
          -> COM_ADM -> COM#1 -> ... ->COM#3 ->

          (continued)
          join1 -> dropped



          to be clearer:
          AO -> RO#1 -> ... -> HBS -> fork1
          
          (path1)
          REV_ADM -> REV#1 -> ... -> REV#3 -> join1
          (path2)
          COM_ADM -> COM#1 -> ... ->COM#3 -> join1
          
          (continued after joined)
          join1 -> dropped
          


          im starting to think that im using wrong perspective. is it okay to continue the execution from inside an action?

          regards,

          rudi

          • 2. Re: Strange behaviour when using fork
            bungrudi
            • 3. Re: Strange behaviour when using fork
              bungrudi

              ok here is an important point for you who happen to stumble into this thread..

              Action handlers _MAY NOT_ continue graph of execution. it means that you cannot do node.leave(), executionContext.leave(), or token.signal() from inside an action handlers.

              There is one case where you are allowed to do those in action handler. In fact, you _MUST_ do one of those in this case. It is when the action handler is in a node of type "Node".

              • 4. Re: Strange behaviour when using fork
                bungrudi

                to jbpm developers,

                it would save me a whole day if you just throw an exception for all unsupported actions, such as calling node.leave() or token.signal() from inside action handler.

                regards,

                Rudi

                • 5. Re: Strange behaviour when using fork
                  bungrudi

                   

                  "bungrudi" wrote:
                  to jbpm developers,

                  it would save me a whole day if you just throw an exception for all unsupported actions,



                  thats a rather self important comment from someone who have just spent his whole day debugging jbpm. :) sorry for that.

                  • 6. Re: Strange behaviour when using fork

                     

                    "bungrudi" wrote:

                    thats a rather self important comment from someone who have just spent his whole day debugging jbpm.

                    But you weren't 'debugging' jBPM, but your own incorrect usage!

                    "bungrudi" wrote:
                    :) sorry for that.

                    And so you should be!

                    • 7. Re: Strange behaviour when using fork
                      bungrudi

                       

                      "pojomonkey" wrote:

                      But you weren't 'debugging' jBPM, but your own incorrect usage!


                      debugging my own app then.

                      "pojomonkey" wrote:
                      And so you should be!


                      i am.
                      but i still think that throwing exception on incorrect usages (like my case) is a good idea.

                      • 8. Re: Strange behaviour when using fork
                        kukeltje

                        it's rather not really easy in the current implementation of the core since it is dependent on the node. The generic actionhandler base then has to have knowledge about which nodes.....

                        In the pvm (basis of 4.0) things will change