Low-code to Kafka
Purpose
Enabling sending messages to the specified Kafka and topic directly from applications (scripts) and BPMN processes (script tasks).
Usage examples
Data update in the data warehouse
Notifying the CRM about process status changes
Communication with external systems (e.g. bank systems)
Use in a script/script task
Please note that the Kafka instance name ("kafkaid" in the example) must be written in lowercase and without special characters.
try {
api.events.v1.publishAsync(
"kafkaid", // Kafka instance name (configured by the administrator, written only in lowercase, without special characters)
"topicName", // topic name (configured by the administrator)
{ // message content – must be valid JSON
"id": "123",
"status": {
"code": "OK",
"message": "Everything is fine!"
},
"list": [1, 2, 3],
"boolean": true,
"date": new Date()
},
"key", // message key (optional – it should be set if we need to preserve the order of events)
{ // headers (optional)
"header1": "header1-value",
"header2": "header2-value"
}
);
} catch (e) {
// error handling
}Important information
Sending is asynchronous – the script does not wait for confirmation of message delivery
Remember to handle exceptions. The function may throw an error if there is no connection to Kafka or if the message buffer in the application overflows
Successful execution of the function confirms that the message was added to the buffer, but does not guarantee that the message is sent without errors. We are unable to catch errors of the sending itself
The message content must be valid JSON – the passed object is automatically serialized
The key is optional, but recommended when you care about message order within a single partition
The sending timeout is configured by the administrator – it cannot be changed from the script
Topics are created and managed by administrators
kafkaIdmust match the name of the Kafka instance configured in the application
Last updated
Was this helpful?
