11 Replies Latest reply on Nov 5, 2005 3:05 AM by tom.baeyens

    fork problem. How execute fork-state completely?

    postponed

      I'm using jbpm3.0. and I need to imitate execution of process, such as there was in jbpm 2.0

      ....
      InvocationLog invocationLog = beanName.startProcessInstance( definition.getId(), map );
       ProcessInstance instance = invocationLog.getProcessInstance();
       beanName.endOfState( instance.getRoot().getId(), null, null );
      

      I thought that it maybe in 3.0 this way:
      while(!processInstance.hasEnded())
       processInstance.signal();
       jbpmSession.close();
      

      It's work only with simple processes. But adding simple fork - and we have that signal "goes" to only one default branch (first transition)..
      How to solve it? Maybe I know how to get round this fork problem. but process state? and so on ? Write it by hands????((((

        • 1. Re: fork problem. How execute fork-state completely?
          bgrissom

          Hi,
          I may not fully understand your problem, but I have run into something similar. Do your transitions all branch from a single state? If you have a node with multiple exiting transitions then you will observe the behavior you described. You need to use a fork node. In that case multiple tokens will be created and your graph will be traversed correctly. I hope that helps. If not can you illistrate your graph or show your XML?

          B Grissom

          • 2. Re: fork problem. How execute fork-state completely?
            postponed

            no, I'm using fork-node! part of process-def-n here:

            <start-state name="start-state">
             <transition to="fork" >
             </transition>
             </start-state>
             <fork name="fork">
             <transition name="to logging" to="logging" />
             <transition name="to authority" to="authority"/>
             </fork>
             <state name="logging" >
             <transition name = "to join" to="join">
             <action class="org.jbpm.billing.LoggingHandler"/>
             </transition>
             </state>
             <state name="authority">
             <transition to="rating process">
             <action class="org.jbpm.billing.AuthorityHandler"/>
             </transition>
             </state>
             <state name="rating process">
             ....
            

            Then, in my application I create a jbpmSession, etc. :
            ...
            JbpmSession jbpmSession =
            JbpmSessionFactory.getInstance().openJbpmSession();
             ProcessDefinition processDefinition =
            jbpmSession.getGraphSession().findLatestProcessDefinition("some process");
             ProcessInstance processInstance = new
            ProcessInstance(processDefinition);
             ContextInstance contextInstance =
            processInstance.getContextInstance();
             contextInstance.addVariables((Map) map);
             while(!processInstance.hasEnded()) {
             processInstance.signal();
             System.out.println("signal");}
             jbpmSession.close();
            

            - with this code I receive to stdout a small of this messages about signal. - Only for start-tate.then fork. Logging. join. an so on in this branch of
            fork. while not receive end-state. But not branch with "authority" and so
            on! AuthorityHandler is not executed!:(
            Maybe I just dont understand jpdl..((

            Thank you for answer. )

            • 3. Re: fork problem. How execute fork-state completely?
              postponed

              please somebody help me!..
              it's my last hope -this forum

              • 4. Re: fork problem. How execute fork-state completely?
                kukeltje

                look at the testcase for forks. You'll see there that in a fork multiple tokens are created and you have to signal each of them individually.

                • 5. Re: fork problem. How execute fork-state completely?
                  postponed

                  ok.and what else about process-state? ammm.. decision also didn't work.. - all of this write by hands? Why? jbpm2 has this ability -

                  ...invocationLog.getProcessInstance();
                   beanName.endOfState...

                  Why in last version of product I have to write it "individually"?%) I dont want think about it) I want to have simple method which can signals all of the child tokens.. and so on..
                  I write it just as ordinary user.. i'm sorry if it seems crude

                  • 6. Re: fork problem. How execute fork-state completely?
                    kukeltje

                    Since it is not 'common' to have a fork and with one trigger signal all sister/brother tokens. If you want a simple method to signal all tokens, create a class, where you pass a token, get the parent token and iterate over all child tokens. You only have to write it once.

                    I do not understand your remark about decision? You want to signal the decision?

                    • 7. Re: fork problem. How execute fork-state completely?
                      postponed

                      yes.. execution of desicion state has troubles too - when I just signal it. And process-state of cource too. Transition is chosen in handler, but token didnt "go" to it.
                      My question was: why didnt You "write it once more"? Cause it's not common task?
                      but for me (and maybe for other users) it isn't "common" ..

                      • 8. Re: fork problem. How execute fork-state completely?
                        kukeltje

                         

                        "postponed" wrote:

                        but for me (and maybe for other users) it isn't "common" ..


                        I think you mean it *is* common? right?

                        Can you give an example where you want to have a fork and signal all parallel nodes at once from the outside? Maybe there are other ways of modelling this.


                        • 9. Re: fork problem. How execute fork-state completely?
                          aparna.krishna

                          Hi
                          Were you able to solve the fork problem? I am in a similar situation too. I want all the child nodes (from the fork) to be traversed.
                          Thanks in advance..

                          • 10. Re: fork problem. How execute fork-state completely?
                            dharraj

                            Hello,

                            Did anybody have a good solution to this problem?

                            Please reply.

                            Thanks

                            • 11. Re: fork problem. How execute fork-state completely?
                              tom.baeyens

                              i didn't read the whole thread so ignore if it was already solved. just replying to the original problem.

                              the problem is that jbpm does not throw an exception when you signal a token that is in a fork. in that case the parent token will take the first leaving transition (maybe we should reconsider and throw an exception instead). you should add an extra check: if there are unfinished child-tokens, you should signal those and not the parent...

                              does this help ?

                              regards, tom.