Working with Kafka
To design interaction with Kafka, you need to add a cube and select the appropriate type:
- Send Message / Send Task (black envelope);
- Receive Message / Receive Task (white envelope);
- Send/Receive Message, custom cube (white and black envelopes).
Sending a Message (Send Task)
On the "General" tab, you need to specify or select the topic name to which the message will be sent. Example:
On the "Input, Output" tab, "Input Parameters" are passed.
The topic name can be specified in the input parameter topic
or set in the "General" tab in the "Event" field.
To pass the message header in the input parameters, add the headers
parameter with the type "Map".
Other variables in the "Input Parameters" tab will go into the message body. Example of specifying input parameters:
Subscription to a Topic
Receiving a Message (Receive Task)
On the "General" tab, specify the topic name similar to sending a message.
On the "Input, Output" tab, in the "Output Parameters" section, list the parameters that need to be obtained from the message body. If the parameters are not listed, then the entire message body will be placed in the process context. Example of specifying output parameters:
Start Event
When it is necessary to start a process upon the appearance of an event in Kafka, use the "StartEvent" cube in BPMN notation.
For the cube, select the type "Message Start Event". For this cube, specify only the topic name to subscribe to. When an event occurs in Kafka, the process will start, and the message attributes (body and headers) will be placed in the process context. Example of specifying the topic name in StartEvent:
Sending/Receiving Message (Send/Receive Task)
Interaction with Kafka can be implemented using a single "Send and Receive Message Task" cube, which combines sending and receiving messages.
To do this, in the left panel of diagram elements, select this element and configure it. The configuration of this cube is done in the same way as when sending and receiving messages - you need to specify topic names and variables for sending/receiving.