Open lukas-foltyn-profinit opened 1 year ago
For others, who would be struggling with Kafka message correlation in Springboot Kogito. There is a simple undocumented way, how to correlate Kafka message in an intermediate message event.
The magic is done by using parameter kogitoprocrefid in the incoming Kafka message - needs to be equal to kogitoprocinstanceid of the workflow which is supposed to receive the message.
{"specversion":"1.0","id":"72c7b329-f7ae-4b0d-b478-3a0bdac38973","source":"","type":"kafka-in","time":"2023-11-13T09:35:52.493428715+01:00","kogitoproctype":"BPMN","kogitoprocinstanceid":"8b80e6c9-4cec-436d-99da-c7c3239736b9","kogitoprocrefid":"8b80e6c9-4cec-436d-99da-c7c3239736b9","kogitoprocist":"Active","kogitoprocversion":"1.0","kogitoprocid":"scripts","data":"Hello Jim"}
If you want to retrieve process instance id programmatically (e.g. you want to send it in some outgoing message), you could use script task with:
kcontext.getProcessInstance().getId();
Description
I tried to prepare a PoC for BPMN which would be based on Kafka messages and Kogito Springboot.
When Kafka message is used in the intermediate event (to move the workflow to the next state), it needs to be correlated - otherwise there is message "No matches found for trigger XXX in process scripts. Skipping consumed message CloudEventWrapDataEvent" displayed.
Although there is quite complex functionality for Collaboration and Correlations in Kogito, I have not found any example for it.
Could you please add an example which would explain how to use Correlations in the editor - ideally with intermediate Kafka message?
BTW, this is part of that PoC, I am trying to solve...
Thanks and regards, Lukas
Implementation ideas
No response