Home / Flowable / Lesson 30

Flowable in a Spring Boot app (live demo)

Extra for developers. A free Flowable lesson in simple English (3:18 minutes).

Sample project: Flowable + Spring Boot (zip)

Install guide (PDF)

Open in the academy (practice, progress and notes)

Chapters

Lesson text

0:00 Introduction

Welcome to this extra lesson for developers. Flowable is not only an application. Its engines are Java libraries, so you can put Flowable inside your own Spring Boot application. Today we run a real Spring Boot app with a leave request process. You can download this project and a step by step install guide below the video. This is an independent course. It is not made or approved by Flowable.

0:25 The project

First, the dependencies in pom dot xml. We need only one Flowable dependency: flowable spring boot starter process. We also add Spring web for a small REST API, and H 2, a small database that lives in memory.

Next, the process. It is a normal BPMN file in the processes folder. When the app starts, Flowable finds every file in this folder and deploys it for us. The user task Approve leave goes to the group managers. Then an exclusive gateway checks the variable approved, and a service task calls a Spring bean named notify employee.

This is the controller. Spring gives us two Flowable services. With the runtime service we start a process instance and pass two variables, employee and days. With the task service we find the tasks for the managers group, and we complete a task with the variable approved.

And this is the Spring bean that the service tasks call. It reads the process variables and prints a message. In a real app, it would send an email.

1:33 Run it

Now we start the application with the Maven wrapper. When Tomcat has started, our app and the Flowable engine are running, and the process is deployed.

We open a second window on the right. Here we act like the employee Asha. She asks for three days of leave. Flowable starts a new process instance.

Now we act like the manager, and ask for the tasks of the managers group. The task Approve leave is waiting, with Asha's name and three days.

We take the task id, and complete the task with approved equals true.

Look at the left window. The gateway chose the approved path, and the service task called our Spring bean: Dear Asha, your leave was approved. If we ask for the tasks again, the list is empty, because the process has ended.

2:53 Summary

Let's review. Add the Flowable starter to a Spring Boot app. Put BPMN files in the processes folder. Use the runtime service to start processes, and the task service to find and complete tasks. Service tasks can call your Spring beans. Download the project below the video and try it yourself. Thank you for learning with us.

Sources