6 Replies Latest reply on Jan 18, 2010 11:12 PM by Shilpa Kumar

    Terminate the task

    Shilpa Kumar Newbie

      I have a task assigned to any user, lets say User1. With some business logic, I want to terminate the task and do not want to move transition ahead. This I am able to achieve in jbpm 3.2 with setSignalling(false) ; But I do not want to terminate the Execution. I tried various APIs. like






      execution.moveTo( DestActivity ) ;


      But still I am not able to achieve the same. Basically I  want to change the outgoing Transition to somewhere back depending on my business logic. Please guide me.


      Thanks in advance.

        • 1. Re: Terminate the task
          Ronald van Kuijk Master
          What is is that you functionality wise want? (so not the technical solution you describe here). In many cases, If a task is canceled, I'd say you go to a new state, so I'd (personally) model these kinds of things in my process
          • 2. Re: Terminate the task
            Shilpa Kumar Newbie

            Hi Ronald,


            Thanks for your reply. I tried 2 approaches.


            Approach 1: I want to terminate the current task, and it should move back to any java activity which might be after Start Node. I don't want to start a new ProcessInstance or Execution. Because it will generate a New ProcessInstance Key. Can I set my code like this?


            ActivityImpl act = processDefinition.findActivity("ActivityName") ;

            execution.getActivity().setDefaultOutgoingTransition( (TransitionImpl) act.getIncomingTransitions().toArray()[0] ) ;


            I tried above code, but I am not able to achieve the same. Do you have any

            wayout for the same.


            Approach 2:

            Please check attach file. Here am unable to achieve the above also. Here I have introduced a fork without a join. But I want to achieve the same. How can I move ahead?


            Thanks again. Waiting for your valuable reply.

            • 3. Re: Terminate the task
              Ronald van Kuijk Master
              What is is that you functionality wise want? (so not the technical solution you describe here).
              • 4. Re: Terminate the task
                Santanu Saraswati Novice

                If you have already arrived at the task then it does not really make sense to cancel the job.


                You can do the first approach you have mentioned in your post. However the code snippet looks complex and I could not make out what are you trying to achieve. This, I thought, can be implemented easily. Let us have a sample flow like this:


                <process name="ForumFlow" xmlns="http://jbpm.org/4.0/jpdl">
                   <start name="start1" g="189,20,48,48">
                      <transition name="to state1" to="state1" g="-49,-18"/>
                   <state name="state1" g="176,116,92,52">
                      <transition name="to task1" to="task1" g="305,205:-44,-18"/>
                   <task name="task1" g="182,252,92,52">
                      <transition name="success" to="end1" g="-42,-18"/>
                      <transition name="cancel" to="state1" g="131,216:-49,-18"/>
                   <end name="end1" g="215,361,48,48"/>


                At the task if you execute when you want to cancel the task you will land you want on cancellation


                taskService.completeTask(taskId, "cancel")


                However, you can provide your usecase as Ronald suggested. Then we can give more relevent code samples.


                Two comments on the flow you uploaded:

                1. I dont think Fork without join make much sense.

                2. Java method name follow camel case convention with the first letter in small. Method names like "SysActivityMet" looks a bit odd.

                • 5. Re: Terminate the task
                  Shilpa Kumar Newbie
                  My use case is very simple. My process is started, and User1 has been assigned and Sub-Process is also started in parallel which also has some task assigned. I want to terminate all the current active activities which are spawned. I want to take the transition back based on business requirement. This should happen at runtime, because the activity where I want to take back will be decided at runtime. Basically I am looking for a reflow of the process.
                  Hope I am able to explain this. Suggestions given by Santanu can be achieved at design time, which is not my requirement. And the comments given by you are wise, but since this is my POC so I am less concern of method names and convention.
                  • 6. Re: Terminate the task
                    Shilpa Kumar Newbie

                    Hi Ronald,


                    Any hint for the above requirement. I gone through most of the source code jBPM 4.1, but not able to figure it out how to move ahead with my requirement.


                    Thanks in advance.