Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-654

Cancelling a TaskInstance "performs" the task

XMLWordPrintable

      If you cancel a task instance by calling taskInstance.cancel(), it calls taskInstance.end() which leads to execution of the task controller in the same way as if the task has been completed normally.

      An example: Imagine an order management system. A user "accidently" enteres an order which leads to the creation of a process instance and a task instance. He realises his mistake and cancels the process instance. If you now cancel the task instance (which is not done automatically, see references below), the task is ended, its token is signalled and the process execution continues (in my case with the creation of several objects) even it has been cancelled before.

      My code for cancelling a process instance and is associated task instances looks like this:

      JbpmContext context = JbpmConfiguration.getInstance().createJbpmContext();
      try
      {
      ProcessInstance instance = context.loadProcessInstanceForUpdate(processInstanceId);
      if (instance != null)
      {
      instance.end();
      for (Iterator it = instance.getTaskMgmtInstance().getTaskInstances().iterator(); it.hasNext()
      {
      TaskInstance taskInstance = (TaskInstance) it.next();
      if (!taskInstance.hasEnded())

      { taskInstance.cancel(); }

      }
      }
      }
      finally

      { context.close(); }

      This issue might be related to:

      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=69609
      http://jira.jboss.com/jira/browse/JBPM-392

            tom.baeyens Tom Baeyens (Inactive)
            sbroetz_jira Stefan Broetz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: