0.1.0
Embedded Zeebe engine
First release of the new shiny embedded zeebe engine. Supports normal java client usage, where the contact point is "0.0.0.0:26500".
Java Client support
You can either use an own simple client like:
val zeebeClient = ZeebeClient.newClientBuilder().usePlaintext().build()
Or get one from the engine:
val zeebeClient = zeebeEngine.createClient()
In memory
The embedded engine is completely in memory, which means the log storage and internal database have been replaced with in memory data structures. This allows to be more performant for unit and intergration tests, then the normal Zeebe broker.
Junit 5 Extension
The first version comes with an Junit 5 Extension, which is ready to use in your next Zeebe side project.
Example:
@EmbeddedZeebeEngine
class EzeExtensionTest {
private lateinit var client: ZeebeClient
@Test
fun `should complete process instance`() {
// given
val process = Bpmn.createExecutableProcess("process")
.startEvent()
.endEvent()
.done()
client.newDeployCommand()
.addProcessModel(process, "process.bpmn")
.send()
.join()
// when
val processInstanceResult = client.newCreateInstanceCommand()
.bpmnProcessId("process")
.latestVersion()
.variables(mapOf("x" to 1))
.withResult()
.send()
.join()
// then
assertThat(processInstanceResult.variablesAsMap)
.containsEntry("x", 1)
}
}
Time travel
The embedded engine supports a "Time travel API". This means you can play with the internal clock to be able to trigger timer events earlier.
zeebeEngine.clock().increaseTime(Duration.ofDays(1))
Records
One main benefit of this new embedded engine is the easy access to the records, which have been produced by the engine.
You can filter for certain record types and use that in your tests.
val processRecordds = zeebeEngine
.processInstanceRecords()
.withElementType(BpmnElementType.PROCESS)
.take(4)
It is not only possible to search and filter for records you can print all or a subset of existing records. Just call print()
on the returned record stream. This is used in the Junit 5 Extension to print the records, when a test fails. It will produce an output like this:
===== Test failed! Printing records from the stream:
11:01:50.415 [main] INFO io.camunda.zeebe.test - Compact log representation:
--------
['C'ommand/'E'event/'R'ejection] [valueType] [intent] - #[position]->#[source record position] P[partitionId]K[key] - [summary of value]
P9K999 - key; #999 - record position; "ID" element/process id; @"elementid"/[P9K999] - element with ID and key
Keys are decomposed into partition id and per partition key (e.g. 2251799813685253 -> P1K005). If single partition, the partition is omitted.
Long IDs are shortened (e.g. 'startEvent_5d56488e-0570-416c-ba2d-36d2a3acea78' -> 'star..acea78'
--------
C DEPLOYMENT CREATE - #1->-1 -1 -
E PROC CREATED - #2->#1 K1 - simpleProcess.bpmn -> "simpleProcess" (version:1)
E DEPLOYMENT CREATED - #3->#1 K2 - simpleProcess.bpmn
E DEPLOYMENT FULLY_DISTR - #4->#1 K2 -
-------------- Deployed Processes ----------------------
simpleProcess.bpmn -> "simpleProcess" (version:1)[K1] ------
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<...>
--------------- Decomposed keys (for debugging) -----------------
-1 <-> -1
K1 <-> 2251799813685249
K2 <-> 2251799813685250
Disclaimer
This embedded engine should not be used on production. It is build for test and development usage. It is far from complete nor is it perfect. It is not fault tolerant, since it is completely in memory and supports only one partition.