Global Event Listener - Error Boundary Event

Hi,

I’m currently working on a simple workflow which contains an error boundary event.
I’m trying to implement an event listener which listens on error boundary events fired.

My company is using Spring (Version: 5.3) in conjunction with Camunda (Version: 7.12).

My current Java class declaration looks like this:

@DependsOn("processEngine")
@Service
@CamundaSelector(type = ActivityTypes.BOUNDARY_ERROR)
@RequiredArgsConstructor
@Lazy(false)
public class GlobalErrorBoundaryEventListener implements ExecutionListener {

I already tried to use “TaskListener” instead of “ExecutionListener” and “ActivityTypes.BOUNDARY_CANCEL” instead of “ActivityTypes.BOUNDARY_ERROR”, but nothing works as expected.

We already use TaskListeners and ExecutionListeners in our software and it works great, so I’m pretty sure I’m just doing it wrong.

I don’t want to have to implement an execution listener and manually add it to every boundary event I want to listen on.
Like this:

<bpmn:boundaryEvent id="Event_1nm5xdu" attachedToRef="ServiceTask_AnderungsvorschriftenInformationenSammeln">
  <bpmn:extensionElements>
    <camunda:executionListener delegateExpression="${eventFiredExpression}" event="start" />
  </bpmn:extensionElements>
  <bpmn:outgoing>Flow_1l13qar</bpmn:outgoing>
  <bpmn:errorEventDefinition id="ErrorEventDefinition_1qgbkjs" camunda:errorCodeVariable="errorCode" camunda:errorMessageVariable="errorMessage" />
</bpmn:boundaryEvent>

Is there a way to listen globally if an error event was fired?

If you need any more information, please let me know.

Have a nice day. :slight_smile:

Can you upload your model?
Generally you should be able to have global error handling using an event sub process, but it depends on your model.

BPMN Workflow:
collectLawchangeComposerElementsByLaw.bpmn (4.7 KB)

Screenshot:
image

And is this pattern being used multiple times in the process model or only this one time?

We use this error boundary event pattern multiple times in our processes.
But we’ve only listened to user task events via “TaskListener” until now.
I want to listen globally if error boundary events are fired.

A pattern like this would like you have a single error even waiting to catch an error from any task

2 Likes

Thank you for this idea. :slight_smile:
I hope this will help someone out there! :wink:

But actually I imagined a much more universal solution for my problem.
I cannot change every process my company uses. We’re talking about hundreds of processes, distributed to different customers.
So I want to be able to hook on to the (Java-side) listener interfaces.

Like this one that we use successfully.
It fires every time a user task is created:

@DependsOn("processEngine")
@CamundaSelector(type = "userTask", event = TaskListener.EVENTNAME_CREATE)
@Service
@RequiredArgsConstructor
@Lazy(false)
public class GlobalTaskCreateListener implements TaskListener {

Isn’t there a possibility to do this for different events in Camunda?

Hi @stefan_geiss,

In the past I had implemented

  @Override
  public void notify(DelegateTask delegateTask) {
    if (TaskListener.EVENTNAME_COMPLETE.equals(delegateTask.getEventName())) {
      // Do this 
    } else if (TaskListener.EVENTNAME_UPDATE.equals(delegateTask.getEventName())) {
      // Do that
    }

But I haven’t had this requirement since long time.

Hope this helps, Ingo

1 Like

Thank you, I will try something like this.
But it’s still not the answer I’m looking for, so I’ll leave this topic open.