@hauptmedia/zeebe-exporter-types
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

Zeebe JSON Export Typescript Types

Compatible with: Camunda Platform 8

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.

Installation

npm i --save @hauptmedia/zeebe-exporter-types

Kafka example

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);

Structure of Zeebe export data

Please follow the links for the detailed documentation of the data structure.

Base Record

Value Types

Package Sidebar

Install

npm i @hauptmedia/zeebe-exporter-types

Weekly Downloads

50

Version

1.3.1

License

Apache-2.0

Unpacked Size

2.22 MB

Total Files

430

Last publish

Collaborators

  • hauptmedia