How to distinguish between the startEvent of activity and the startEvent of Process itself

Hello Team,

I am using Camunda spring boot starter version 7.16 and using Spring Eventing bridge for executing our own logic during an event (for eg., startEvent, endEvent etc). We need to execute some logic while triggering of the startEvent of my activity. We have done that but it is getting triggered twice. The first one is the startEvent for process itself and the second startEvent is for my activity. I need the execute my logic only for the activity’s startEvent. Kindly help me to know how can I distinguish between the startEvent for both the events. All the state variables are same for both the events. The same is true for endEvent too. Thanks in advance for the response.
In this post Double emit of start and end-event in spring eventing bridge - #6 by McAlm a way to distinguish has been mentioned but it is not working.


1 Like

The spring starter publishes the DelegateExecution as event, so unless you apply a custom filter, your EventListener is called every time.

The solution is to use a filter expression in the EventListeners “conditional” element.

@EventListener(conditional = "#execution.getCurrentActivityId().equals(start)")
void handle(DelegateExecution execution) {...}

Hello @jangalinski ,
Thanks for your response. I understand that we can provide conditions as part of the EventListener annotation, but for the startEvent there are two events which are getting triggered, one for the startEvent activity of the process and another for the process itself. The same is true for end events too. The variables and states values present in both the event triggers are one and equal.
For e.g., the eventName for both are “start”, the value for execution.getBpmnModelElementInstance().getElementType().getTypeName() is also “startEvent” for the event triggers.
I need my custom logic to be executed only during startEvent activity of the process and not twice. Kindly let me know, using which value we can find the difference between both the event triggers.

Ok, wow, I wouldn’t have expected this behavior. No, no idea out of the box, but I am curious now, so I will hopefully find some time to investigate …

Thanks @jangalinski . I was using Camunda BPM Reactor before (for past 3 years) for executing logic based on events. I am not getting the process startEvent trigger for the CamundaSelector of type “startEvent” and event “start”. The camunda bpm reactor logic is filtering the startEvent for process and only giving the trigger for startEvent activity. I am also checking on that code whether any filter has been applied in that logic.
Kindly help by investigating through EventListener and let me know. Thanks in advance for your help.

Hello @jangalinski Did you get a chance to take a look on the above mentioned issue? Thanks in advance for your response.