I’m pretty new to Camunda and I’m trying to implement something I think should be straight forward, but I’m struggling.
I want to use CamundaBPM as a simple event orchestrator - it should receive 2 events from Kafka, do something (like aggregate the payload of both messages), and then publish a new event to Kafka.
In my mind it would look something like the following:
In my Spring application I have 2 KafkaListeners, which trigger the start of a process when a message is received, with a parallel gateway at the other end:
if you use the correlation id as a business key when sending the message to camunda the following model would work.
It would start a new process in cases where an instance doesnt exist and continue an existing one in cases were the process exists with the same business key
So in your suggested flow, if I understand correctly, we are creating 2 distinct process instances, depending on which message is received first through kafka.
If we take the top flow and assume that we have received ‘message one’ from a listener first:
The kafka listener will start the process instance by calling the following (and we can provide a trace ID as the business key as you suggested):
Following this, another kafka listener gets message 2 - it also calls something similar to start the process flow, because it doesn’t know if it should start a new process instance, or continue an existing process instance:
Programatically, how should I handle this to ensure it either continues with the existing flow, or starts a new process instance? How do I correlate the business keys together?
I made the following updates, which does work sporadically (or for the first time when I send in 2 messages on occasion), so something still isn’t quite right: