Mule Activiti Integration

February 4
blog author

Appno Blogger

Appnovation Coop

1. Introduction

This post is intended to show how to connect to Activiti business process management system using Activiti REST API within a MuleSoft Integration Application. We assume that you already have Activiti installed and configured to use a standalone database in MySql running inside Tomcat web server.

For this post I used the most recent Activiti version that is 5.17.0. Also the Activiti user guide, available here Ref[1] is a good reference to do all the required setup and have Activiti up and running.

2. Use Cases

Create an endpoint that allows Activiti Administrators to get all deployed Activiti business processes.

Start an Activiti process using the processDefinitionKey parameter and the exposed REST API.

3. Demo Application

The demo application is available here Ref[2] in GIT, It is comprised of two flows:

Admin flow: as depicted by the following, this flow is used to get all deployed Activiti processes:

<flow name="activiti-Flow1" doc:name="activiti-Flow1">
 <http:inbound-endpoint  host="localhost" port="7070" path="test"
              exchange-pattern="request-response" contentType="application/json"/>
 <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8080"
              path="activiti-rest/service/repository/deployments" method="GET" doc:name="HTTP"
              contentType="application/json" password="kermit" user="kermit"/>        
 <logger message="#[payload]" category="INFO" doc:name="Logger"/>

The following is an example of the expected payload response that depends on the running Activiti instance I am using and thus the deployed business processes:
"data": [{
"id": "20001",
"name": "Account Creation",
"deploymentTime": "2014-12-24T12:48:16.906-05:00",
"category": null,
"url": "http://localhost:8080/activiti-rest/service/repository/deployments/20001",
"tenantId": ""
"id": "23",
"name": "Demo processes",
"deploymentTime": "2014-12-22T21:33:42.091-05:00",
"category": null,
"url": "http://localhost:8080/activiti-rest/service/repository/deployments/23",
"tenantId": ""
"id": "41",
"name": "Demo reports",
"deploymentTime": "2014-12-22T21:33:44.291-05:00",
"category": null,
"url": "http://localhost:8080/activiti-rest/service/repository/deployments/41",
"tenantId": ""
"total": 3,
"start": 0,
"sort": "id",
"order": "asc",
"size": 3

The following illustrates the deployed Account Creation business process that is returned when we invoke the URL:



In the next section, we will see how to start the deployed business process: Account Creation. The corresponding XML accountcreation.bpmn20.xml shows that the process id is create-account, the latter is required as a parameter to start the process using REST.

To explore Activiti exposed REST API, check the REST API section within the Activiti user guide as shown in Ref [1].

Start Process flow: this flow as illustrated within the following figure, starts the business process with the name Account Creation and the processDefinitionKey=create-account which is the process id in the XML.

<flow name="activiti-Flow2" doc:name="activiti-Flow2">
  <jms:inbound-endpoint queue="StartPIQueue" connector-ref="Active_MQ" doc:name="JMS"/>
  <logger message="####### INPUT PAYLOAD JSON: ######## :  #[payload]" category="INFO"/>
  <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8080"
                 path="activiti-rest/service/runtime/process-instances" method="POST"
                 doc:name="HTTP" contentType="application/json"
                 password="${activiti.username}" user="${activiti.password}"/>
 <byte-array-to-string-transformer doc:name="Byte Array to String"/>     
 <logger message="####### RESPONSE PAYLOAD  ######## :  #[payload]" category="INFO"/>

 The JMS queue expects a json payload as illustrated by the following:


The code snippet that runs a test and starts the process is illustrated in the following:

 MuleClient client = new MuleClient(muleContext);
 String payload = "{\"processDefinitionKey\":\"create-account\"}";
 MuleMessage result = client.send("jms://StartPIQueue", payload, null);

The returned response is illustated in the following:


The previous response indicates that the process has been started but it is not yet completed, the process completion needs a human action.

Open the Activiti explorer using your favorite web explorer:



Click on Tasks link and Queued to view the started process as illustrated within the following:

To complete the process click on the button Claim, the process is then moved to Inbox.

Click on Inbox and hit the button Complete task as depicted within the following:


 We have demonstrated how to invoke Activiti REST API to start a process instance in Activiti, as well as how to get all deployed processes in Activiti using simple HTTP calls via inbound endpoints and forwarding the request to a subsequent outbound endpoint that do the job of invoking the REST API, passing along the username and the password for the Basic Authentication required by Activiti server instance.

In the next post I will demonstrate how to simplify the complexities of REST API calls and develop a custom cloud connector for Activiti.


4. References