Writing a custom exporter in Camunda 8.6 (for Zeebe) involves creating a Java class that implements the io.camunda.zeebe.exporter.api.Exporter
interface. This lets you process and export records from the Zeebe engine to an external system (like Elasticsearch, a database, or a file).
Here’s a step-by-step guide:
1. Add dependencies
In your pom.xml (for Maven):
<dependency>
<groupId>io.camunda</groupId>
<artifactId>zeebe-exporter-api</artifactId>
<version>8.6.0</version>
</dependency>
2. Implement the Exporter Interface
Create a class that implements Exporter:
import io.camunda.zeebe.exporter.api.context.Context;
import io.camunda.zeebe.exporter.api.Exporter;
import io.camunda.zeebe.protocol.record.Record;
public class MyCustomExporter implements Exporter {
@Override
public void configure(Context context) {
// Initialize resources, config, logger, etc.
context.getLogger().info("Configuring MyCustomExporter");
}
@Override
public void open(Controller controller) {
// Start any long-lived resources or background processes
}
@Override
public void export(Record<?> record) {
// Handle the record (e.g., send to a DB, log it, etc.)
System.out.println("Exporting record: " + record.getValueType());
}
@Override
public void close() {
// Clean up resources
}
}
3. Create the Exporter JAR
Package the class in a JAR using Maven:
mvn clean package
4. Add Exporter to Zeebe Brokers
Place the JAR inside the broker container or host file system at:
/usr/local/zeebe/exporters/
And configure it in the broker config (usually application.yaml):
exporters:
myExporter:
className: com.yourpackage.MyCustomExporter
jarPath: exporters/my-exporter.jar
You can also use Helm values if deploying with Helm:
zeebe:
broker:
exporters:
myExporter:
className: com.yourpackage.MyCustomExporter
jarPath: exporters/my-exporter.jar
5. Restart the Broker
Once deployed and configured, restart your Zeebe broker. You should see logs from your exporter if it’s working.