AnsweredAssumed Answered

Java Service Task custom asynchronous behaviour: Complete task using signal or callback.

Question asked by saraiva on May 10, 2016
Latest reply on May 18, 2016 by jbarrez
Hello, this has already been answered but the solutions have not been working out for me.

Activiti asynchronous behaviour is fairly simple and only allows the user to enable a flag which tells activiti engine to insert such task in a execution queue (managing a pool of threads).

What i want is not to insert my java service task in a pool but to passivate its behaviour and only complete such task when an external signal is received and/or a callback is called.

My attempt:

    class customAsyncTask extends TaskActivityBehavior {
      override def execute(execution: ActivityExecution): Unit = {
        val future = Future {
          println(s"Executing customAsyncTask -> ${execution.getCurrentActivityName}, ${cur}")

        future.onComplete {
          case Success(result) => leave(execution)
          case _ => // whatever
      def signal(processInstanceId : String, transition : String) = {
        val commandExecutor  = main.processEngine.getProcessEngineConfiguration.asInstanceOf[ProcessEngineConfigurationImpl].getCommandExecutor
        val command = new customSignal(processInstanceId, transition)

On my previous code sample i have registered a scala future callback which when called will terminate the current activity and move to the next.

I also have a signal method which builds a custom signal that based on the processId and a name will call execution.take with the appropriate transition.

On both cases i am getting the following error (the bottom stack changes a little):

   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(
   at org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(

Unfortunately, it is highly likely that the engine is erasing the information concerning the execution when the execute method returns, even though no complete/leave/take has been called. Even though my callback has the execution object in context, when i query for information using its proccess ID all i receive is null.

So, what i am doing wrong here? How can i achieve the behaviour that i want?