How can the Spring Eventing Bridge only listen to the events of the designated Node?

Spring Eventing Bridge,How can the global executionListener only listen to the events of the UserTask Node?Thanks !

Hello @mrzhangbq ,

you could register your own BpmnParseListenerand refer to the org.camunda.bpm.spring.boot.starter.event.PublishDelegateParseListener which registers the execution listeners. In your own implementation, you could then register your own event to be published.

Hope this helps

Jonathan

@EventListener(condition = “#delegateExecution.bpmnModelElementInstance.elementType.typeName==‘userTask’”)
public void onExecutionEvent(DelegateExecution delegateExecution) {
// handle the execution event of UserTask Node
}

Thanks ! I found another way to achieve this effect . like this ,
@EventListener(condition = “#delegateExecution.bpmnModelElementInstance.elementType.typeName==‘userTask’”)
public void onExecutionEvent(DelegateExecution delegateExecution) {
// handle the execution event of UserTask Node
}

2 Likes

Hello @mrzhangbq ,

I like this way as well as you use Spring Boot tooling :slight_smile:
Thanks a lot for sharing your solution.

Jonathan

Just an addition … in case you do not like the SPEL syntax for Eventlistener#condition or you have to perform more complex checks, you can use a dedicated bean/predicate to do so:

  @EventListener(condition = "@myComplexPredicate.test(#execution)")

When you provide a java.util.Predicate you can apply your filtering logic in its “test” method, with the advantage that you have full compiler support, can test your filter and even exchange the filter logic via spring configuration (profiles/primary/…) in case you need different behaviour for testing or certain stages.

I am not saying that this must be used, it is just a convenient addition that is good to know abbout.