Process status change event listener

Hi!
How Can I subscribe on a running process? I would like to log or check If the process status has been changed.

After this: Long instanceId = zeebe.newCreateInstanceCommand()
.bpmnProcessId(processId)
.latestVersion()
.variables(processVariableMap)
.send()
.join()
.getProcessInstanceKey();

I tried @JobWorker with a handler method but an event received only ACTIVED status. I need COMPLETED status too if the process ran or not. how can I do this? Thank you!

zeebe.newWorker()
.jobType(“io.camunda:http-json:1”)
.handler((jobClient, job) → {
// Handle the process instance event
long processInstanceKey = job.getProcessInstanceKey();

                ProcessInstance processInstance = camundaService.getProcessInstance(processInstanceKey);
                switch(processInstance.getState()) {
                    case COMPLETED:
                        log.info("Process completed with key: {}", processInstanceKey);
                        break;
                    case ACTIVE:
                        log.info("Process failed with key: {}", processInstanceKey);
                        break;
                    case CANCELED:
                        log.info("Process canceled with key: {}", processInstanceKey);
                        break;
                }

                // Complete the job
                jobClient.newCompleteCommand(job.getKey()).send().join();
            })
            .open();

bpmn:extensionElements
<zeebe:taskDefinition type=“io.camunda:http-json:1” />
zeebe:ioMapping

Hi @Zoltan_Karolyi
You might be interested in reading this post - Platfrom 8 task and execution listeners - #4 by Philipp_Ossler

Regards,
Alex

Hi! Thank you. I want to send a massage into Kafka if the process is activated ,completed or there are an INCIDENT. Could you help what I should do? Thank you!

In Camunda 8, and since it’s based on event-driven arch, you need to read more about and be familiar with Zeebe Exporter. Luckily, in your case, there is one for Kafka which might deliver what are you trying to achive:
Kafka Zeebe Exporter

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.