JULY 11, 2019

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: https://www.cockroachlabs.com/docs/stable/install-cockroachdb.html

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 http://start.spring.io/ 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 application.properties 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) {  
    SpringApplication._run_(Application.**class**, 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.

Joram Barrez_MG 7807

Joram Barrez

Principal Software Architect

A core developer at Flowable with over a decade of experience in open source software and of building scalable process engines. He co-founded the Activiti project (on which Flowable is based) and was part of the JBoss jBPM team before that.

Share this Blog post
Engineering | SEPTEMBER 21, 2023

Flowable Open Source 7.0.0 release

Today, we are happy to share that we have released Flowable 7.0.0. As a Flowable community user this means, you can start working with Spring Boot 3 and requires Java 17 as a baseline. Read more

Engineering | JUNE 21, 2023

Specifying data structure with a new model type: Data Dictionary

Data is a crucial part of modeling and executing cases and processes. Our new module, Data Dictionary, empowers modelers to define which data structures and constraints are needed in the case or process model and all its child models.Read more

Adobe Stock 121826479
Engineering | JUNE 20, 2023

Unveiling the new Flowable Design: A closer Look

The new Flowable Design shines with a completely new user interface whilst maintaining backward compatibility to the previous version. In this article, we highlight some of the new features and technical details.Read more