AnsweredAssumed Answered

Process instance behavior change on the fly

Question asked by tomekzaremba on Feb 8, 2016
Latest reply on Feb 9, 2016 by tomekzaremba
Hi,

I'm trying to provide the "goto" solution for running process instance. It should be available as rest endpoint (Activiti is integrated with Spring Boot). Purpose of that is to modify standard process execution in case of e.g. error in one of the service task or retry some already completed task.

I tried following snippet of code:


final ProcessDefinitionImpl definition = (ProcessDefinitionImpl) repositoryService //
                .getProcessDefinition(data.getProcessDefinitionId());
        final ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery() //
                .executionId(data.getExecutionId()) //
                .singleResult();

        final ActivityImpl desiredActivity = definition.findActivity(data.getActivityId());
        execution.setActivity(desiredActivity);

        AtomicOperation.ACTIVITY_START.execute(execution);


but it ends with following NPE:


Caused by: java.lang.NullPointerException: null
   at org.activiti.engine.impl.history.handler.ActivityInstanceStartHandler.notify(ActivityInstanceStartHandler.java:30) ~[activiti-engine-5.19.0.1.jar:5.19.0.1]
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:42) ~[activiti-engine-5.19.0.1.jar:5.19.0.1]
   at pl.play.support.SupportRestController.gotoStep(SupportRestController.java:118) ~[classes/:na]


Can anyone can give me some hint how to implement such mechanism? Of course this has to change only given by my process instance - whole process definition should be unchanged.

Outcomes