Typescript type & JSON Schema definitions for JSON encoded export data used by the Zeebe Workflow Automation Engine.
You can find the JSON Schema definitions of the Zeebe Events here.
npm i --save @hauptmedia/zeebe-exporter-types
This example shows how to leverage this library to process JSON encoded Zeebe event data coming from Kafka.
Use the zeebe-kafka-exporter for Zeebe to export event data to Kafka.
You can find the example project in examples/kafka.
import {
dispatchZeebeRecordToHandler,
NoOpZeebeRecordHandler,
ProcessInstanceRecordValue,
ValueType,
ZeebeRecord,
ZeebeRecordHandlerInterface
} from "@hauptmedia/zeebe-exporter-types";
import {Kafka} from 'kafkajs';
class MyRecordHandler extends NoOpZeebeRecordHandler implements ZeebeRecordHandlerInterface {
// Override the methods for the records you want to process or implement ZeebeRecordHandlerInterface
processInstance(record: ZeebeRecord<ProcessInstanceRecordValue>) {
console.log(`${record.intent} ${record.value.bpmnElementType} ${record.value.elementId}`);
}
}
const kafka = new Kafka({
clientId: 'exampleClientId',
brokers: ['localhost:9093']
}),
zbRecordHandler = new MyRecordHandler(),
consumer = kafka.consumer({groupId: 'exampleGroupId'});
const run = async () => {
await consumer.connect()
await consumer.subscribe({topic: "zeebe"})
await consumer.run({
eachMessage: async ({topic, partition, message, heartbeat, pause}) => {
if (!message.value)
return;
dispatchZeebeRecordToHandler(
JSON.parse(message.value.toString()) as ZeebeRecord<ValueType>,
zbRecordHandler
);
},
})
}
run().catch(console.error);
Please follow the links for the detailed documentation of the data structure.
Generated using TypeDoc