Getting Started with Flowable and CockroachDB

In Flowable 6.4.2, support for CockroachDB was added. We’ve sat together with the engineers from Cockroach Labs (the company behind CockroachDB) to make sure we’ve got the details right and to exchange feedback both ways.

After all, CockroachDB (called CRDB in next paragraphs) is not a ‘regular database’. According to it’s Github page, it’s a cloud-native SQL database for building global, scalable cloud services that survive disasters. It is a distributed SQL database built on a transactional and strongly-consistent key-value store. It scales horizontally; survives disk, machine, rack, and even datacenter failures with minimal latency disruption and no manual intervention.

What makes CRDB very interesting for Flowable is that it’s scalable and distributed database (simply add more nodes to the cluster to cope with more load or store data closer to where it is used) that is fully ACID transactional. In the world of processes and cases, atomicity is utmost importance, as data correctness is sacred.

Furthermore, it also means we can reuse all the existing code in the engines that’s been there for many years and which is battle-hardened by being used by many companies all over the world.

Let’s show how to get started with running the Flowable engines on top of CockroachDB. To make things a bit more interesting, let’s build a simple Spring Boot application that starts a process instance when a REST endpoint is hit.

(Note: obviously the CRDB integration also works in a non-Spring setup)

Step 1: Start CRDB

Download Cockroach from its website:

In a terminal, to start it, execute

./cockroach start --insecure --host=localhost

Note that this is a simple (non-production) setup with only one node in insecure mode. See the docs for other ways of running it, including clustered.

We need a database and user to connect from our application. From the terminal, execute following commands which will create a flowable database and a flowable user.

./cockroach sql --insecure -e 'CREATE DATABASE flowable'
./cockroach sql --insecure -e 'CREATE USER flowable'
./cockroach sql --insecure -e 'GRANT ALL ON DATABASE flowable to flowable'

Step 2: Creating the project

Create a new Spring Boot application (e.g. by going to and generating an empty project) and add the following dependencies:


We’ve added

  • The Flowable Spring Boot starter dependency. This will automatically create all Flowable engines (bpmn / cmmn / dmn) using the CRDB datasource.
  • The PostgreSQL jdbc driver. CRDB is compatible with PostgreSQL (read about that in detail here), which makes it easy to reuse a plethora of tools out there.
  • The Spring Boot web starter that we need to craft the REST endpoint.

Step 2: Configuring the application

Flowable needs to know how to connect to the database. Add an file to the resources:


Step 3: The application

The application is a simple Spring Boot application. It has a RestController that has one method that starts a process instance (the process definition is actually in the processes folder of the resources and it automatically picked up).

The ProcessEngine and its services are created automatically and configured to use the CRDB database. As shown in the example below, they are automatically injected in the controller:

public class Application {

public static void main(String[] args) {, args);

class MyRestController {

private RuntimeService runtimeService;
private TaskService taskService;

public MyRestController(final RuntimeService runtimeService, final TaskService taskService) {
this.runtimeService = runtimeService;
this.taskService = taskService;

public void startProcessInstance() {

System.out.println("Number of tasks created: " + taskService.createTaskQuery().count());



Step 4: Running it

After starting the application (from your IDE or terminal), the REST endpoint can now be called:

curl http://localhost:8080/start

which will output

Number of tasks created: 1
Number of tasks created: 2
Number of tasks created: 3

which proves it works (you can query the database using any SQL tool to verify the data is in fact there) and demonstrates that using CockroachDB with Flowable is exactly the same as running it against any other relational database.