Cannot get process instance start time inside JavaDelegate

In my process I use a JavaDelegate to save some information about the execution in a DB. The executions are scheduled to run each minute, and every time they finish they write on the DB. One of the informations I need to save is the total time of execution. The problem is that I can’t get the start time of my process. In fact, if I use RuntimeService inside the delegate, it throws nullpointerexception, and I think that is because it is @Autowired and doesn’t work when the flow is called by the timer event triggered after the deploy.
I can only use DelegateExecution, but I couldn’t find a method to get the info.
How can I retrieve this information?

Hi,

Yes you can use the info from the DelegateExecution.

ExecutionEntity processInstanceExecution = CommandContextUtil.getExecutionEntityManager().findById(execution.getProcessInstanceId());
Date startTime = processInstanceExecution.getStartTime();

In this way the cache is used to fetch the process instance execution.

Best regards,

Tijs

1 Like