Detecting Process Starts and Process End from DelegateExecution object

I have registered a global execution listener to listen for everything happening in my process application. I needed to detect when a process starts and when it ends from the DelegateExecution class object passed on in the handler for the listener.
Is there any way I can get this information using the Java API. I couldnt find anything in the Java docs.

Hi @asarvaiya

You can call execution.getEventName() to get the event name (“start”, “end” or “take”)
Keep in mind the following

The events that can be captured are:
•Start and end of a process instance.
•Taking a transition.
•Start and end of an activity.
•Start and end of a gateway.
•Start and end of intermediate events.
•Ending a start event or starting an end event.

1 Like

I was aware of this function but as you pointed out, this will not only indicate a start of a process but start of any activity in general. Is there a way to find out just the process has started. I was thinking of using a standard name such as “startProcess****” and “endProcess****” for the start and end events of the process. But I wanted to know if there was any generic way to find that out from the DelegateExecution object. Also, I am not sure if the execution listener fires when the process starts or is it just for each activity of the workflow.

See below post

Returns the currently executed Element in the BPMN Model. This method returns a FlowElement which may be casted to the concrete type of the Bpmn Model Element currently executed.

If called from a Service ExecutionListener, the method will return the corresponding FlowNode for ExecutionListener.EVENTNAME_START and ExecutionListener.EVENTNAME_END and the corresponding SequenceFlow for ExecutionListener.EVENTNAME_TAKE.

The thing is that the concrete type for process start and the one for sub process (expanded sub process inside the parent process) is the same. Is there any way I can find that the process start is for the parent process

You can check the returned value of getParentId()
If null then it means the start of the process in your case.

String getParentId()
Gets the id of the parent of this execution. If null, the execution represents a process-instance