Skip to content

Commit 23d2abc

Browse files
committed
Add example on using a BPMN process as an External Task Worker
1 parent b811f4f commit 23d2abc

File tree

18 files changed

+819
-0
lines changed

18 files changed

+819
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# External Task Worker Process
2+
An example on using a BPMN process as an External Task Worker for [Camunda BPM](http://docs.camunda.org).
3+
4+
This project has been generated by the Maven archetype
5+
[camunda-archetype-servlet-war-7.10.1-SNAPSHOT](http://docs.camunda.org/latest/guides/user-guide/#process-applications-maven-project-templates-archetypes).
6+
7+
## Show me the important parts!
8+
[BPMN Process](src/main/resources/process.bpmn)
9+
10+
![BPMN Process](src/main/resources/process.png)
11+
12+
## How does it work?
13+
14+
## How to use it?
15+
16+
### Unit Test
17+
You can run the JUnit test [InMemoryH2Test](src/main/resources/archetype-resources/src/test/java/InMemoryH2Test.java) in your IDE or using:
18+
```bash
19+
mvn clean test
20+
```
21+
22+
### Deployment to an Application Server
23+
You can also build and deploy the process application to an application server.
24+
For an easy start you can download Apache Tomcat with a pre-installed Camunda
25+
from our [Download Page](https://camunda.com/download/).
26+
27+
#### Manually
28+
1. Build the application using:
29+
```bash
30+
mvn clean package
31+
```
32+
2. Copy the *.war file from the `target` directory to the deployment directory
33+
of your application server e.g. `tomcat/webapps` or `wildfly/standalone/deployments`.
34+
For a faster 1-click (re-)deployment see the alternatives below.
35+
36+
#### Apache Tomcat (using Maven AntRun Plugin)
37+
1. First copy the file `build.properties.example` to `build.properties`
38+
2. Edit the `build.properties` file and put the path to your Tomcat into `deploy.tomcat.dir`.
39+
3. Build and deploy the process application using:
40+
```bash
41+
mvn clean package antrun:run
42+
```
43+
44+
Alternatively, you can also copy the `build.properties` file to `${user.home}/.camunda/build.properties`
45+
to have a central configuration that works with all projects generated by the
46+
[Camunda Maven Archetypes](http://docs.camunda.org/latest/guides/user-guide/#process-applications-maven-project-templates-archetypes) e.g. the [examples provided by the Camunda Consulting Team](https://github.com/camunda-consulting/code).
47+
48+
#### Apache Tomcat (using Tomcat Maven Plugin)
49+
1. Create a user in Tomcat with the role `manager-script`.
50+
2. Add the user's credentials to the `tomcat7-maven-plugin` configuration in the [pom.xml](pom.xml) file.
51+
3. Build and deploy the process application using:
52+
```bash
53+
mvn clean tomcat7:deploy
54+
```
55+
56+
#### Wildfly (using Wildfly Maven Plugin)
57+
1. Build and deploy the process application using:
58+
```bash
59+
mvn clean wildfly:deploy
60+
```
61+
62+
#### JBoss AS7 (using JBoss AS Maven Plugin)
63+
1. Build and deploy the process application using:
64+
```bash
65+
mvn clean jboss-as:deploy
66+
```
67+
68+
#### Ant (and Maven)
69+
1. First copy the file `build.properties.example` to `build.properties`
70+
2. Edit the `build.properties` file and put the path to your application server inside it.
71+
3. Build and deploy the process application using:
72+
```bash
73+
ant deploy.tomcat
74+
```
75+
or
76+
```bash
77+
ant deploy.jboss
78+
```
79+
80+
Alternatively, you can also copy the `build.properties` file to `${user.home}/.camunda/build.properties`
81+
to have a central configuration that works with all projects generated by the
82+
[Camunda Maven Archetypes](http://docs.camunda.org/latest/guides/user-guide/#process-applications-maven-project-templates-archetypes) e.g. the [examples provided by the Camunda Consulting Team](https://github.com/camunda-consulting/code).
83+
84+
### Run and Inspect with Tasklist and Cockpit
85+
Once you deployed the application you can run it using
86+
[Camunda Tasklist](http://docs.camunda.org/latest/guides/user-guide/#tasklist)
87+
and inspect it using
88+
[Camunda Cockpit](http://docs.camunda.org/latest/guides/user-guide/#cockpit).
89+
90+
## Environment Restrictions
91+
Built and tested against Camunda BPM version 7.11.0.
92+
93+
## Known Limitations
94+
95+
## License
96+
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
97+
98+
<!-- HTML snippet for index page
99+
<tr>
100+
<td><img src="snippets/external-task-worker-process/src/main/resources/process.png" width="100"></td>
101+
<td><a href="snippets/external-task-worker-process">External Task Worker Process</a></td>
102+
<td>An example on using a BPMN process as an External Task Worker for [Camunda BPM](http://docs.camunda.org).</td>
103+
</tr>
104+
-->
105+
<!-- Tweet
106+
New @Camunda example: External Task Worker Process - An example on using a BPMN process as an External Task Worker for [Camunda BPM](http://docs.camunda.org). https://github.com/camunda-consulting/code/tree/master/snippets/external-task-worker-process
107+
-->
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copy this file to 'build.properties' and modify it to match your system
2+
# Alternatively, you can also copy it to '${user.home}/.camunda/build.properties'
3+
# to have a central configuration that works with all camunda BPM projects
4+
5+
# Defines the deployment folder in a camunda BPM installation (backslashes need to be escaped or replaced by forward slashes).
6+
deploy.jboss.dir=C:/camunda/camunda-bpm-jboss-7.11.0/server/jboss-as-7.2.0.Final/standalone/deployments
7+
deploy.tomcat.dir=C:/camunda/camunda-bpm-tomcat-7.11.0/server/apache-tomcat-8.0.47/webapps
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="external-task-worker-process" default="deploy.jboss">
3+
4+
<property file="build.properties" />
5+
<property file="${user.home}/.camunda/build.properties" />
6+
<property name="target.dir" value="target" />
7+
8+
<condition property="mvn.executable" value="mvn.bat" else="mvn">
9+
<os family="windows"/>
10+
</condition>
11+
12+
<target name="package.mvn">
13+
<exec executable="${mvn.executable}" dir="." failonerror="true">
14+
<env key="MAVEN_OPTS" value="-Xmx1024m -Xms512m -DskipTests=true -Dmaven.test.skip=true" />
15+
<arg line="clean install" />
16+
</exec>
17+
</target>
18+
19+
<target name="deploy.jboss" depends="package.mvn, copy.war.into.jboss" description="Copies the process application to the deployment directory defined in '${basedir}/build.properties' or '${user.home}/.camunda/build.properties'" />
20+
21+
<target name="copy.war.into.jboss">
22+
<fail unless="deploy.jboss.dir" message="No deployment folder has been configured. Please copy the file '${basedir}/build.properties.example' to '${basedir}/build.properties' or '${user.home}/.camunda/build.properties' and change it according to your environment." />
23+
<copy file="${target.dir}/${ant.project.name}.war" todir="${deploy.jboss.dir}" />
24+
</target>
25+
26+
<target name="undeploy.jboss" description="Deletes the process application from the deployment directory defined in '${basedir}/build.properties' or '${user.home}/.camunda/build.properties'">
27+
<delete file="${deploy.jboss.dir}/${ant.project.name}.war" />
28+
</target>
29+
30+
<target name="deploy.tomcat" depends="package.mvn, copy.war.into.tomcat" description="Copies the process application to the deployment directory defined in '${basedir}/build.properties' or '${user.home}/.camunda/build.properties'" />
31+
32+
<target name="copy.war.into.tomcat">
33+
<fail unless="deploy.tomcat.dir" message="No deployment folder has been configured. Please copy the file '${basedir}/build.properties.example' to '${basedir}/build.properties' or '${user.home}/.camunda/build.properties' and change it according to your environment." />
34+
<copy file="${target.dir}/${ant.project.name}.war" todir="${deploy.tomcat.dir}" />
35+
</target>
36+
37+
<target name="undeploy.tomcat" description="Deletes the process application from the deployment directory defined in '${basedir}/build.properties' or '${user.home}/.camunda/build.properties'">
38+
<delete file="${deploy.tomcat.dir}/${ant.project.name}.war" />
39+
</target>
40+
41+
</project>
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.camunda.bpm.example</groupId>
6+
<artifactId>external-task-worker-process</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
9+
<packaging>war</packaging>
10+
11+
<name>External Task Worker Process</name>
12+
<description>An example on using a BPMN process as an External Task Worker for [Camunda BPM](http://docs.camunda.org). [The project has been generated by the Maven archetype 'camunda-archetype-servlet-war-7.10.1-SNAPSHOT']</description>
13+
14+
<properties>
15+
<camunda.version>7.11.0</camunda.version>
16+
<!--
17+
Adjust if you want to use Camunda Enterprise Edition (EE):
18+
<camunda.version>7.11.0-ee</camunda.version>
19+
Make sure you also switch to EE repository below
20+
-->
21+
<maven.compiler.source>1.8</maven.compiler.source>
22+
<maven.compiler.target>1.8</maven.compiler.target>
23+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24+
<failOnMissingWebXml>false</failOnMissingWebXml>
25+
</properties>
26+
27+
<dependencyManagement>
28+
<dependencies>
29+
<dependency>
30+
<groupId>org.camunda.bpm</groupId>
31+
<artifactId>camunda-bom</artifactId>
32+
<version>${camunda.version}</version>
33+
<scope>import</scope>
34+
<type>pom</type>
35+
</dependency>
36+
</dependencies>
37+
</dependencyManagement>
38+
39+
<dependencies>
40+
<dependency>
41+
<!-- process engine, needs to be 'provided' because it's already a shared library in the container -->
42+
<groupId>org.camunda.bpm</groupId>
43+
<artifactId>camunda-engine</artifactId>
44+
<scope>provided</scope>
45+
</dependency>
46+
47+
<dependency>
48+
<!-- AssertJ Testing Library -->
49+
<groupId>org.camunda.bpm.extension</groupId>
50+
<artifactId>camunda-bpm-assert</artifactId>
51+
<version>1.2</version>
52+
<scope>test</scope>
53+
</dependency>
54+
55+
<!-- Required to use Spin dataformat support in unit tests -->
56+
<dependency>
57+
<groupId>org.camunda.spin</groupId>
58+
<artifactId>camunda-spin-dataformat-all</artifactId>
59+
<scope>test</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.camunda.bpm</groupId>
63+
<artifactId>camunda-engine-plugin-spin</artifactId>
64+
<scope>test</scope>
65+
</dependency>
66+
67+
<!-- Required to use Templates in unit tests -->
68+
<dependency>
69+
<groupId>org.camunda.template-engines</groupId>
70+
<artifactId>camunda-template-engines-freemarker</artifactId>
71+
<scope>test</scope>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.camunda.template-engines</groupId>
75+
<artifactId>camunda-template-engines-velocity</artifactId>
76+
<scope>test</scope>
77+
</dependency>
78+
79+
<dependency>
80+
<groupId>javax.servlet</groupId>
81+
<artifactId>javax.servlet-api</artifactId>
82+
<version>3.1.0</version>
83+
<scope>provided</scope>
84+
</dependency>
85+
86+
<dependency>
87+
<groupId>junit</groupId>
88+
<artifactId>junit</artifactId>
89+
<version>4.12</version>
90+
<scope>test</scope>
91+
</dependency>
92+
93+
<dependency>
94+
<!-- Needed for InMemoryH2Test -->
95+
<groupId>com.h2database</groupId>
96+
<artifactId>h2</artifactId>
97+
<version>1.4.197</version>
98+
<scope>test</scope>
99+
</dependency>
100+
101+
<dependency>
102+
<!-- Used to generate test coverage reports, see https://github.com/camunda/camunda-consulting/tree/master/snippets/camunda-bpm-process-test-coverage -->
103+
<groupId>org.camunda.bpm.extension</groupId>
104+
<artifactId>camunda-bpm-process-test-coverage</artifactId>
105+
<version>0.3.2</version>
106+
<scope>test</scope>
107+
</dependency>
108+
109+
<dependency>
110+
<!-- use logback as logger -->
111+
<groupId>ch.qos.logback</groupId>
112+
<artifactId>logback-classic</artifactId>
113+
<version>1.1.3</version>
114+
<scope>test</scope>
115+
</dependency>
116+
117+
<dependency>
118+
<groupId>org.slf4j</groupId>
119+
<!-- apache commons logging => slf4j -->
120+
<artifactId>jcl-over-slf4j</artifactId>
121+
<version>1.7.25</version>
122+
<scope>test</scope>
123+
</dependency>
124+
125+
<dependency>
126+
<!-- java util logging => slf4j -->
127+
<groupId>org.slf4j</groupId>
128+
<artifactId>jul-to-slf4j</artifactId>
129+
<version>1.7.25</version>
130+
<scope>test</scope>
131+
</dependency>
132+
133+
<!-- Add your own dependencies here, if in compile scope, they are added to the war -->
134+
135+
</dependencies>
136+
137+
<repositories>
138+
<repository>
139+
<id>camunda-bpm-nexus</id>
140+
<name>Camunda Maven Repository</name>
141+
<url>https://app.camunda.com/nexus/content/groups/public</url>
142+
</repository>
143+
<!-- enable this for EE dependencies (requires credentials in ~/.m2/settings.xml)
144+
<repository>
145+
<id>camunda-bpm-nexus-ee</id>
146+
<name>Camunda Enterprise Maven Repository</name>
147+
<url>https://app.camunda.com/nexus/content/repositories/camunda-bpm-ee</url>
148+
</repository>
149+
-->
150+
</repositories>
151+
152+
<build>
153+
<finalName>${project.artifactId}</finalName>
154+
<plugins>
155+
<plugin>
156+
<!-- Deploy to Tomcat using: mvn clean package antrun:run
157+
Follow the instructions in build.properties.example to make it work!-->
158+
<groupId>org.apache.maven.plugins</groupId>
159+
<artifactId>maven-antrun-plugin</artifactId>
160+
<configuration>
161+
<tasks>
162+
<ant antfile="${basedir}/build.xml">
163+
<target name="copy.war.into.tomcat" />
164+
</ant>
165+
</tasks>
166+
</configuration>
167+
</plugin>
168+
<!-- Tomcat Maven Plugin
169+
170+
Deploy to Tomcat using:
171+
mvn clean tomcat7:deploy
172+
173+
Redeploy:
174+
mvn clean tomcat7:redeploy
175+
176+
Undeploy:
177+
mvn tomcat7:undeploy
178+
179+
To use this plugin, add these lines to your tomcat-users.xml: (inside the <tomcat-users>-tag)
180+
<role rolename="manager-script"/>
181+
<user username="admin" password="admin" roles="manager-script"/>
182+
183+
-->
184+
<plugin>
185+
<groupId>org.apache.tomcat.maven</groupId>
186+
<artifactId>tomcat7-maven-plugin</artifactId>
187+
<version>2.2</version>
188+
<configuration>
189+
<url>http://localhost:8080/manager/text</url>
190+
<username>admin</username>
191+
<password>admin</password>
192+
</configuration>
193+
</plugin>
194+
<plugin>
195+
<!-- Deploy to JBoss AS7: mvn clean jboss-as:deploy See also: https://docs.jboss.org/jbossas/7/plugins/maven/latest/examples/deployment-example.html -->
196+
<groupId>org.jboss.as.plugins</groupId>
197+
<artifactId>jboss-as-maven-plugin</artifactId>
198+
<version>7.9.Final</version>
199+
</plugin>
200+
<plugin>
201+
<!-- Deploy to Wildfly: mvn clean wildfly:deploy See also: https://docs.jboss.org/wildfly/plugins/maven/latest/examples/deployment-example.html -->
202+
<groupId>org.wildfly.plugins</groupId>
203+
<artifactId>wildfly-maven-plugin</artifactId>
204+
<version>2.0.1.Final</version>
205+
</plugin>
206+
</plugins>
207+
</build>
208+
</project>

0 commit comments

Comments
 (0)