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
Blog post React UI header
Business | MARCH 24, 2022

Reacting when your UI framework reaches end of life

Our long-serving automation editing application, Flowable Design, was built using the AngularJS UI framework. Time to react. Well, to React.Read more

Engineering | FEBRUARY 17, 2022

Running Flowable with Spring Native

In this post, we'll look at what it takes to run Flowable on GraalVM using the latest Spring Native release.Read more

Flowable engineering blog post hero
Engineering | SEPTEMBER 7, 2021

Flowable orchestration of Microsoft Power Automate Desktop – RPA for free

In this post, I’m going to show you how to run Microsoft’s RPA product from Flowable.  The full and complete way of doing this is by using Microsoft Power Automate Cloud to remotely drive Microsoft …Read more