Process Application Event Listeners in Quarkus Application

Hello!

I’m trying to setup a small project using an EmbeddedProcessApplication in a Quarkus Setup.
The goal is to listen to all Task & Execution Events and publish them to an external event bus (probably Kafka).

While the initial setup is running, the Listeners are not being called during execution.

This is what the process application class looks like:

@ProcessApplication(
    name="core-quarkus"
)
public class Core extends EmbeddedProcessApplication {
    @Inject
    public RuntimeService runtimeService;

    @Transactional
    public void onStartup(@Observes CamundaEngineStartupEvent o) {
        String processInstanceId = runtimeService.startProcessInstanceByKey("Test_Process").getId();
        System.out.println("Process instance with id " + processInstanceId + " started!");
    }

    @Override
    public TaskListener getTaskListener() {
        return new TaskListener() {
            public void notify(DelegateTask delegateTask) {
                // handle all Task Events from Process
                System.out.println("Task Listener was notified...");
            }
        };
    }

    @Override
    public ExecutionListener getExecutionListener() {
        return new ExecutionListener() {
            public void notify(DelegateExecution execution) throws Exception {
                // handle all Execution Events from Process
                System.out.println("Execution Listener was notified...");
            }
        };
    }

To load the ProcessApplicationEventListenerPlugin programmatically, I added another class:

@ApplicationScoped
public class CoreProcessEngineConfig extends QuarkusProcessEngineConfiguration {
    public CoreProcessEngineConfig() {
        System.out.println("Custom engine config is applied...");
        setProcessEngineName("coreProcessEngine");

        List<ProcessEnginePlugin> processEnginePlugins = new ArrayList<>();
        processEnginePlugins.add(new ProcessApplicationEventListenerPlugin());
        setProcessEnginePlugins(processEnginePlugins);
    }
}

This seems to work, at least when starting up Quarkus with ./mvnw compile quarkus:dev, I’m seeing the output that the plugin is loaded and the process is started.

2022-07-19 10:29:25,697 INFO  [org.cam.bpm.eng.cfg] (Quarkus Main Thread) ENGINE-12003 Plugin 'ProcessApplicationEventListenerPlugin' activated on process engine 'coreProcessEngine'

2022-07-19 10:29:25,702 INFO  [org.cam.fee.FeelEngine] (Quarkus Main Thread) Engine created. [value-mapper: CompositeValueMapper(List(org.camunda.feel.impl.JavaValueMapper@1f33c26f)), function-provider: org.camunda.bpm.dmn.feel.impl
.scala.function.CustomFunctionTransformer@207dbbaf, clock: SystemClock, configuration: Configuration(false)]
2022-07-19 10:29:30,200 INFO  [org.cam.bpm.engine] (Quarkus Main Thread) ENGINE-00001 Process Engine coreProcessEngine created.
2022-07-19 10:29:30,203 INFO  [org.cam.bpm.eng.jobexecutor] (Quarkus Main Thread) ENGINE-14014 Starting up the JobExecutor[org.camunda.bpm.quarkus.engine.extension.impl.ManagedJobExecutor].
2022-07-19 10:29:30,205 INFO  [org.cam.bpm.eng.jobexecutor] (pool-20-thread-1) ENGINE-14018 JobExecutor[org.camunda.bpm.quarkus.engine.extension.impl.ManagedJobExecutor] starting to acquire jobs
Process instance with id e8bbfeee-073c-11ed-8159-005056c00008 started!
2022-07-19 10:29:30,258 INFO  [io.quarkus] (Quarkus Main Thread) core 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.10.2.Final) started in 5.099s.
2022-07-19 10:29:30,260 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2022-07-19 10:29:30,261 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [agroal, camunda-platform-engine, cdi, confluent-registry-avro, jdbc-mariadb, kafka-client, narayana-jta, smallrye-context-propagation, vertx]     
2022-07-19 10:29:30,263 INFO  [io.qua.dep.dev.RuntimeUpdatesProcessor] (Aesh InputStream Reader) Live reload total time: 5.383s

Does someone have an idea what I’m missing / doing wrong?

Thanks in advance! Best regards, Hendrik

Solved it similarly to this solution: Create Execution Listener in Spring[Modified] - #5 by mpichler
by defining my own ProcessEnginePlugin containing a BpmnParseListener.