How to implement Activiti REST API with Spring Boot Example
Tags: springboot, restapi, activiti
Published: 2021-04-29 16:19:26

https://grokonez.com/java-integration/activiti-rest-api-spring-boot-example

How to implement Activiti REST API with Spring Boot Example

In this tutorial, we're gonna look at an example that uses Activiti REST API with Spring Boot.

Related Articles:
- <a href="https://grokonez.com/java/introduction-activity-java-bpm-engine">Introduction to Activiti – a Java BPM Engine</a>
- <a href="https://grokonez.com/spring-framework/spring-boot/start-activiti-spring-jpa-spring-boot">How to start Activiti + Spring JPA with Spring Boot</a>

<!--more-->
<div id="tuttoc" class="jsa-toc"></div>

<div id="tutcontents">
<h2>I. Activiti REST API Overview</h2>
Activiti Engine includes a REST API that can be used by:
- deploying the <strong>activiti-rest.war</strong> file to a servlet container,
- or including the servlet and it’s mapping in the application and add all activiti-rest dependencies to the classpath.

By default the Activiti Engine will connect to an in-memory H2 database, so with Spring Boot, we just need to add dependency as below to make it run:
<pre><code class="language-html">&lt;dependency&gt;
	&lt;groupId&gt;com.h2database&lt;/groupId&gt;
	&lt;artifactId&gt;h2&lt;/artifactId&gt;
&lt;/dependency&gt;

&lt;dependency&gt;
	&lt;groupId&gt;org.activiti&lt;/groupId&gt;
	&lt;artifactId&gt;activiti-spring-boot-starter-basic&lt;/artifactId&gt;
	&lt;version&gt;5.22.0&lt;/version&gt;
&lt;/dependency&gt;

&lt;dependency&gt;
	&lt;groupId&gt;org.activiti&lt;/groupId&gt;
	&lt;artifactId&gt;spring-boot-starter-rest-api&lt;/artifactId&gt;
	&lt;version&gt;5.17.0&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>
Activiti REST API supports:
<ul>
	<li><strong>Deployment</strong>: get/create/delete Deployments, get resources inside a Deployment.</li>

	<li><strong>Process Definition</strong>: get one or list of Process Definitions, get resource content or BPMN model of a Process Definition, activate/suspend, get/add/delete candidate starters.</li>

	<li><strong>Model</strong>: get/update/create/delete Models, get/set editor source for a Model.</li>

	<li><strong>Process Instance</strong>: get/delete/activate/suspend Process Instances, add/remove Users, get/create/update Variables.</li>

	<li><strong>Execution</strong>: get Executions, execute an action or get active activities, query, get/create/update Variables.</li>

	<li><strong>Task</strong>: get/update/delete Tasks, query for Tasks, get/create/update Variables, get/create/delete identity links, get Events, get/create/delete Attachments.</li>

	<li><strong>History</strong>: get/delete/query for Historic Process Instances, Task Instances, Activities Instances, Variables Intances.</li>

	<li><strong>User</strong> & <strong>Group</strong>: get/create/update/delete information.</li>

	<li><strong>Database Table</strong>, <strong>Engine</strong>, <strong>Runtime</strong>, <strong>Job</strong>...</li>
</ul>
For more details, please visit: <a href="https://www.activiti.org/userguide/#_rest_api">Activiti User Guide - REST API</a>

In the example, we will test some of them to see how it works.
<h2>II. Practice</h2>
<h3>1. Technology</h3>
- Java 1.8
- Maven 3.3.9
- Spring Tool Suite – Version 3.8.4.RELEASE
- Spring Boot: 1.5.3.RELEASE
<h3>2. Step by step</h3>
<h4>2.1 Create Spring Boot project</h4>
Using Spring Tool Suite/Eclipse to create Project and add Dependencies to <strong>pom.xml</strong> file:

https://grokonez.com/java-integration/activiti-rest-api-spring-boot-example

How to implement Activiti REST API with Spring Boot Example