9 Replies Latest reply on Nov 16, 2010 10:53 AM by LX T

    Migrate app to jBPM - multiple starts

    LX T Newbie

      Hi,

       

      I need to migrate from an existing non jBPM application.

       

      For new executions(start-end) everything is fine.

       

      But some flow executions have to start in the middle(practically can be at any state within the process).

      Multiple starts are not possible.

      How can I accomplish this?

       

      A big decission up-front and then transition to every process state does not seem a good way.

       

      Would you recommend another solution?

       

      Thank you.

        • 1. Re: Migrate app to jBPM - multiple starts
          jinlin ning Newbie

          This my way to start up in the middle:

           

          step 1:

          save the Variable in the map when I star the processInstance :

           

          map.put("startInMiddle", true);

          this.executionService.startProcessInstanceByKey("chooseSite",map);

           

          step 2:

           

          add the assign-handdler or event-listener to all the activity you don't want to handle

           

          like this:

          @Override
              public void assign(Assignable assignable,
                      OpenExecution execution) throws Exception {

                   ExecutionImpl e = (ExecutionImpl) execution;

                   e.getVariable("starInMiddle").toString().equals(true){

                         e.execution).end();
                    }      
              }

          • 2. Re: Migrate app to jBPM - multiple starts
            LX T Newbie

            Thanks for sharing the info.

             

            My test process is like this:

            -------------------------------------------------------------------------------------------------------------------

             

            <?xml version="1.0" encoding="UTF-8"?>

             

            <process name="Custom" xmlns="http://jbpm.org/4.3/jpdl">

             

              <start g="20,20,48,48">
                <transition to="node1"/>
              </start>
             
              <java class="org.jbpm.examples.custom.Node1" g="96,16,100,52" method="hello" name="node1">     
                <transition to="node2"/>
              </java>
             
              <java class="org.jbpm.examples.custom.Node2" g="243,17,100,52" method="hello" name="node2">     
                <transition to="end"/>
              </java> 
             
              <end g="422,20,80,40" name="end"/>

             

            </process>

            -------------------------------------------------------------------------------------------------------------------

             

            I have no experience with assign-handler, can you guide me a little, maybe with an example? Thank you.

            • 3. Re: Migrate app to jBPM - multiple starts
              LX T Newbie

              I want some executions to skip Node 1 and do just Node 2 for example.

              • 4. Re: Migrate app to jBPM - multiple starts
                jinlin ning Newbie

                I was wondering why do you choose to use java node ? the java node don't have the property of assign-handler

                Try to use the state replace your java node , and add a start event listener

                <on event="start">
                        <event-listener class="org.jbpm.examples.eventlistener.LogListener">
                          <field name="msg"><string value="start on activity wait"/></field>
                        </event-listener>
                      </on>

                 

                 


                  public void notify(EventListenerExecution execution) {

                     ExecutionImpl e = (ExecutionImpl) execution;

                         e.getVariable("starInMiddle").toString().equals(true){

                               e.execution).end();

                   
                  }

                • 6. Re: Migrate app to jBPM - multiple starts
                  LX T Newbie

                  I am using the java node because I need to execute some java in each node.

                  • 7. Re: Migrate app to jBPM - multiple starts
                    LX T Newbie

                    Hi Ning,

                     

                    Thanks for info. With an event listener I can execute something on start of every node.

                     

                    But if in the listener I do: ((ExecutionImpl) execution).getExecution().end();

                    the execution is ended.

                     

                    How can I do in the listener to end just the current activity?

                     

                    Regards.

                    • 8. Re: Migrate app to jBPM - multiple starts
                      LX T Newbie

                      I've tried:

                       

                      ActivityExecution activityExecution = (ActivityExecution) event;
                      activityExecution.takeDefaultTransition();

                       

                      but I get:

                      org.jbpm.api.JbpmException: implementation bug: couldn't find parent activity(node1) around destination activity(node2)

                      • 9. Re: Migrate app to jBPM - multiple starts
                        LX T Newbie

                        The jBPM dev guide is saying:

                         

                        6.3. Event listener API

                        ... the execution flow cannot be changed by the event listeners

                         

                        so I think the execution can not be changed from listener.