Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-8965

Allow TaskListener/ExecutionListener/HistoryEvent via spring eventing

      When

      • process application is being build with the help of Camunda Spring Boot and @EnableProcessApplication annotation.

      Then

      Currently, there is no straightforward way to use global listeners together with @EnableProcessApplication annotation.

      Related discussions:
      https://github.com/camunda/camunda-bpm-spring-boot-starter/issues/184#issuecomment-414703217
      https://forum.camunda.org/t/preferred-way-to-use-process-application-event-listener/2238/3

        This is the controller panel for Smart Panels app

            [CAM-8965] Allow TaskListener/ExecutionListener/HistoryEvent via spring eventing

            Comment from jan.galinski@holisticon.de:

            You might know my extension camunda-bpm-reactor. It uses the (meanwhile discontinued) reactor-eventbus and registers via parse-listener for all event hooks, and you can then subscribe to events and thus implement global taskListeners without changing the models.

            I made an approach to adopt this behavior to spring boot with just relying on the spring event publishing.

            see https://github.com/camunda/camunda-bpm-spring-boot-starter/pull/298

            you can then implement listeners via

              // simple check for ebentName
              @EventListener(condition = "#execution.eventName.equals('start')")
              fun report(execution: DelegateExecution):Unit {
                println("1-${execution.currentActivityId}-${execution.eventName}")
              }
            
              // everything
              @EventListener
              fun report2(execution: DelegateExecution):Unit {
                println("2-${execution.currentActivityId}-${execution.eventName}")
              }
            
              // predicate for complex checks
             @Bean
              fun onCreateOfTask086nqxm() : Predicate<DelegateTask> = Predicate {
                it.eventName == TaskListener.EVENTNAME_CREATE && "Task_086nqxm" == it.taskDefinitionKey
              }
            
              // only for creation of certain task
              @EventListener(condition = "@onCreateOfTask086nqxm.test(#task)")
              fun report(task: DelegateTask):Unit {
                println("3-${task.taskDefinitionKey}-${task.eventName}")
              }
            

            Svetlana Dorokhova added a comment - Comment from jan.galinski@holisticon.de : You might know my extension camunda-bpm-reactor. It uses the (meanwhile discontinued) reactor-eventbus and registers via parse-listener for all event hooks, and you can then subscribe to events and thus implement global taskListeners without changing the models. I made an approach to adopt this behavior to spring boot with just relying on the spring event publishing. see https://github.com/camunda/camunda-bpm-spring-boot-starter/pull/298 you can then implement listeners via // simple check for ebentName @EventListener(condition = "#execution.eventName.equals( 'start' )" ) fun report(execution: DelegateExecution):Unit { println( "1-${execution.currentActivityId}-${execution.eventName}" ) } // everything @EventListener fun report2(execution: DelegateExecution):Unit { println( "2-${execution.currentActivityId}-${execution.eventName}" ) } // predicate for complex checks @Bean fun onCreateOfTask086nqxm() : Predicate<DelegateTask> = Predicate { it.eventName == TaskListener.EVENTNAME_CREATE && "Task_086nqxm" == it.taskDefinitionKey } // only for creation of certain task @EventListener(condition = "@onCreateOfTask086nqxm.test(#task)" ) fun report(task: DelegateTask):Unit { println( "3-${task.taskDefinitionKey}-${task.eventName}" ) }

              yana.vasileva Yana Vasileva
              jan.galinski@holisticon.de Jan Galinski
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: