Flowable Notes for Beginners

Flowable Notes for Beginners

1. Flowable is a set of process and tasks inside it.

Example snippet (as per bpmn20.xml):

Below snippet is only for understanding on how the process and tasks will be created in flowable for any bpmn process.


  • couponupload is process id/key created to upload the coupons for a particular shop.
  • This process will have set of tasks in order to complete the whole process, here totally 2 process, one is store already partnered or not and whether the category already available or not.

<process id="couponupload" name="Coupon Upload BPMN Process" isExecutable="true">
<userTask id="store-already-partnered" name="Check whether the store is already partnered or not" flowable:assignee="${ storeName }" flowable:candidateGroups="InternalMaintenanceTeam" flowable:dueDate="${ storeCreationDueDate }">
<modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>

<userTask id="category-already-available" name="Check whether the particular shops category is available or not" flowable:assignee="${ categoryName }" flowable:candidateGroups="InternalMaintenanceTeam">
<modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>


2. Installing Flowable and configuring with Apache Tomcat

You have to download flowable-6.4.0(latest while writing this article) and download the apache tomcat, then move all the below five war files to webapps then do tomcat restart for the deployments.

  1. flowable-admin.war
  2. flowable-idm.war
  3. flowable-modeler.war
  4. flowable-rest.war
  5. flowable-task.war

Then you will be able to see the list of flowable wars deployed in the manager of apache tomcat in this url

Url to access:

Default username and password:
username: admin
password: test

Upload your bpmn20.xml file in flowable-modeler, probably in this page http://localhost:8080/flowable-modeler

Note: Apache tomcat may be asking you to enter username and password for manager-gui/console, for that you have to do the below simple step.

Go to apache/conf/tomcat-users.xml file and paste the below snippet, (please take the backup of tomcat-users.xml file  before modifying anything)

<?xml version='1.0' encoding='utf-8'?>
<role rolename="manager-gui"/>
<user username="root" password="root" roles="manager-gui"/>


For more details read the below link,

Tomcat 7, 8, 9 Default password setting guidelines.


3. RuntimeService is a class available to start bpmn process.

private RuntimeService runtimeService;

Here RuntimeService is autowired and started the flowable process using startProcessInstanceByKey method,


Note: couponupload is the process id mentioned in the xml above(or the Model key as per the flowable diagram created, which looks similar to the below popup), processMeta can be passed to process as maps.

4. TaskService is also a class available in flowable to initiate / play / work around with the flowable tasks.

private TaskService taskService;

Fetching the list of tasks for a particular assignee:

// this just fetches the list of tasks by the assignee name.

List<Task> tasks = taskService.createTaskQuery().taskAssignee(assignee).orderByDueDateNullsLast().desc().list();

5. Deleting a process with process_id

Process_id can be taken from the “act_ru_task” table “PROC_INST_ID_” column

private RuntimeService runtimeService;

runtimeService.deleteProcessInstance(processInstanceId, "test");

@DeleteMapping(value = "/process/{processInstanceId}")
public boolean deleteLmImplementationByProcess(@PathVariable("processInstanceId") String processInstanceId) {

runtimeService.deleteProcessInstance(processInstanceId, "test");

return true;


6. How to get the process varialbles saved back from flowable tables

//Here executionid, is the task key id.

Map<String, Object> processVariables = runtimeService.getVariables(task.getExecutionId());

String taskDefKey = StringUtils.trimToEmpty(task.getTaskDefinitionKey());

// this returns the coupons process variables saved.


7. How to create a diagram in flowable ?

Flowable Modeler can be used to create any new BPMN process flowable diagrams. Please make sure flowable installation is completed properly before trying to open the below link,


Process -> Create Process

We have different flows like manual task, end event, choice gateway, timer trigger, intermediate events etc.

Along with that you will also find a different tasks like user task/Script task/Business rule task/Receive task/Manual task/Mail task/Camel task/Http task/Mule task/Send task/Shell task/Decision task.

Mainly we need to fill the fields for every tasks like id(unique to identity and process the task), assignee to take the flow properly with respect to the allowed flowable users, Delegate expression like sending/notifying some updates to involved groups and category(this one can be reused to identify if different flows are using the same functionality).

8. How to configure a Delegate services in Flowable ?

In the flowable, we may require sms/email notifications sometime, this can be configured using JavaDelegate provided in the flowables.

This will be triggered when delegate expression enabled in the BPMN processes.

import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;

public class SMSDelegate implements JavaDelegate {

public void execute(DelegateExecution execution) {
// your business goes here.


9. Working with Execution Listeners:

If you want to listen to some task and do some other task then execution listeners are good option in flowable.

Here in this case smsListener task will be listened here and executes the notify method, so that if anything else needs to be run in parallel with sms tasks then this can be utilized effectively in flowable.

import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Component;

public class SmsListener implements ExecutionListener {

public void notify(DelegateExecution execution) {
// your business goes here


10. How to create Dynamic Tasks in Flowable and Map against particular process ID?

[code lang=”java”]
TaskService taskService;

Task flowableDynamicTask = taskService.newTask();
flowableDynamicTask.setAssignee(“Assignee Name”);

If you like to map this dynamic flowable task agains any process, then before saving / calling .saveTask() method set the process Id Also for the flowable dynamic tasks.


11. How to trigger a particular task or process in asynchronous way ?

When we are doing some synchronous calls and waiting for some kind of asynchronous responses from any external systems, then triggering the task after that async call is really a important stuff to know and work to allow the flowable to flow when we are using flowable BPMN.

Here you can consider passing your process instance id and activity id to your synchronous call itself, because these both are mandatory to get the flowable execution object to call trigger method as it internally takes the execution ID.

[code lang=”java”]

RuntimeService runtimeService;

public void triggerFlow(){

// pass YOURPROCESSINSTANCEID and YOURACTIVITYID to get the flowable execution object

Execution execution = runtimeService.createExecutionQuery().processInstanceId(YOURPROCESSINSTANCEID)





12. How to start the flowable BPMN process from your main java class ?

This below main method will load the database from your localhost and tries to load the coupon_publish_workflow.xml bpmn from src/main/resources/flowable-processes folder.

And inside the sample xml it has lot of process and subprocesses, we have to give the main process key that is coupon_publish_start in the runtimeservice.startProcessInstanceByKey method to start the BPMN process from your own created xml BPMN.

[code lang=”java”]

public static void main(String[] args) {
ProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration()

ProcessEngine processEngine = cfg.buildProcessEngine();

RepositoryService repositoryService = processEngine.getRepositoryService();
Deployment deployment = repositoryService.createDeployment().addClasspathResource(“flowable-processes\\coupon_publish_workflow.xml”)

ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
System.out.println(“Found process definition : ” + processDefinition.getName());

RuntimeService runtimeService = processEngine.getRuntimeService();

// refer the key in coupon_publish_workflow.xml file.
ProcessInstance pi = runtimeService.startProcessInstanceByKey(“coupon_publish_start”);




13. How to trigger or set the process variables for a particular process using flowable rest ?

Below is the link which can be used to set the process variable against the particular process definition key.

Here admin is username and test is password, which is directly mentioned in the below url and the same can be hit using Postman.


[I assume you have already completed flowable setup steps and able to access localhost:8080 and flowable stuffs]

Sample Body Request:

{ “processDefinitionKey”: “your_flowable_process_definition_key”,

“returnVariables”: true,
“variables”: [{
“name”: “your_variable”,
“value”: “value”}

1,582 total views, 4 views today

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.