3 Replies Latest reply on Mar 10, 2014 5:49 AM by Mauricio Salatino

    Async workitem handler not working in jbpm 6.0.1?

    munish agarwal Newbie

      I need to verify a use case where the manaul task is completed asyncronously. As suggested in the documentation and several posts I have done the following. However when the completeWorkItem is called in the inner thread an IlleagelState exception is thrown. Seems like the runtime of the orignal process and the runtime of the thread in which the task is trying to be completed are different which is not acceptable to JBPM.


      Help? I have attached the complete project which has a junit for async as well as sync workhandler. Also attached is the exception trace.












      class AsyncMockManualTaskHandler implements WorkItemHandler {

      private RuntimeEngine runtime;

      public AsyncMockManualTaskHandler(RuntimeEngine runtime) {

      this.runtime = runtime;


      public void abortWorkItem(WorkItem arg0, WorkItemManager arg1) {

      // We do not need to do this.}

      public static final String EXECUTION_ID = "executionId";


      public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {

      new AsyncTaskCompleter(workItem, runtime).start();



      class AsyncTaskCompleter extends Thread {

      private RuntimeEngine runtime;

      workItem = null;

      public AsyncTaskCompleter(WorkItem workItem, RuntimeEngine runtime) {

      this.runtime = runtime;

      this.workItem = workItem;



      public void run() {

         runtime.getKieSession().getWorkItemManager().completeWorkItem(workItem.getId(), null);