Skip to content

Commit be2e823

Browse files
committed
Merge branch 'release/0.4.4'
2 parents 072c1f3 + 62d39b0 commit be2e823

File tree

25 files changed

+94000
-137
lines changed

25 files changed

+94000
-137
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
[![incubating](https://img.shields.io/badge/lifecycle-INCUBATING-orange.svg)](https://github.com/holisticon#open-source-lifecycle)
55
[![Development branches](https://github.com/bpm-crafters/process-engine-worker/actions/workflows/development.yml/badge.svg)](https://github.com/bpm-crafters/process-engine-worker/actions/workflows/development.yml)
6-
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.bpm-crafters.process-engine-worker/process-engine-worker-spring-boot-starter/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.bpm-crafters.process-engine-worker/process-engine-worker-spring-boot-starter)
6+
[![Maven Central Version](https://img.shields.io/maven-central/v/dev.bpm-crafters.process-engine-worker/process-engine-worker-spring-boot-starter)](https://central.sonatype.com/artifact/dev.bpm-crafters.process-engine-worker/process-engine-worker-spring-boot-starter)
7+
78

89
## Purpose of the library
910

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This example deploys three processes into an embedded process engine.
2+
Using Camunda Tasklist, start processes manually:
3+
4+
* Simple - will execute the worker successfully.
5+
* Simple with Error - will create an incident and report correct exception in Camunda.
6+
* Simple with BPMN Error - will throw BPMN Error and process will react to that.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
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+
<parent>
6+
<groupId>dev.bpm-crafters.process-engine-worker</groupId>
7+
<artifactId>process-engine-worker-examples</artifactId>
8+
<version>0.4.4</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
12+
<artifactId>process-engine-worker-example-camunda7-embedded-starter-transaction</artifactId>
13+
<description>Example: Transactional behavior of external task client using C7 embedded</description>
14+
15+
<dependencyManagement>
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-dependencies</artifactId>
20+
<version>${spring-boot.version}</version>
21+
<scope>import</scope>
22+
<type>pom</type>
23+
</dependency>
24+
<dependency>
25+
<groupId>dev.bpm-crafters.process-engine-adapters</groupId>
26+
<artifactId>process-engine-adapter-camunda-platform-c7-bom</artifactId>
27+
<version>${process-engine-adapters-c7.version}</version>
28+
<scope>import</scope>
29+
<type>pom</type>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.camunda.bpm</groupId>
33+
<artifactId>camunda-bom</artifactId>
34+
<version>7.23.0</version>
35+
<scope>import</scope>
36+
<type>pom</type>
37+
</dependency>
38+
</dependencies>
39+
</dependencyManagement>
40+
41+
<dependencies>
42+
<dependency>
43+
<groupId>org.springframework.boot</groupId>
44+
<artifactId>spring-boot-starter-web</artifactId>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.springframework.boot</groupId>
48+
<artifactId>spring-boot-starter-data-jpa</artifactId>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.springframework.boot</groupId>
52+
<artifactId>spring-boot-starter-actuator</artifactId>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.springdoc</groupId>
56+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
57+
<version>2.8.9</version>
58+
</dependency>
59+
60+
<dependency>
61+
<groupId>dev.bpm-crafters.process-engine-worker</groupId>
62+
<artifactId>process-engine-worker-spring-boot-starter</artifactId>
63+
</dependency>
64+
<dependency>
65+
<groupId>dev.bpm-crafters.process-engine-adapters</groupId>
66+
<artifactId>process-engine-adapter-camunda-platform-c7-embedded-spring-boot-starter</artifactId>
67+
</dependency>
68+
69+
<dependency>
70+
<groupId>org.camunda.bpm.springboot</groupId>
71+
<artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.camunda.bpm</groupId>
75+
<artifactId>camunda-engine-plugin-spin</artifactId>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.camunda.spin</groupId>
79+
<artifactId>camunda-spin-dataformat-json-jackson</artifactId>
80+
</dependency>
81+
<dependency>
82+
<groupId>io.holunda</groupId>
83+
<artifactId>camunda-platform-7-autologin</artifactId>
84+
<version>2025.06.1</version>
85+
</dependency>
86+
<dependency>
87+
<groupId>com.h2database</groupId>
88+
<artifactId>h2</artifactId>
89+
</dependency>
90+
91+
</dependencies>
92+
93+
<build>
94+
<plugins>
95+
<plugin>
96+
<groupId>org.jetbrains.kotlin</groupId>
97+
<artifactId>kotlin-maven-plugin</artifactId>
98+
</plugin>
99+
</plugins>
100+
</build>
101+
</project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package dev.bpmcrafters.example.camunda7embedded
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication
4+
import org.springframework.boot.runApplication
5+
6+
fun main() = runApplication<ExampleEmbeddedApplication>().let { }
7+
8+
@SpringBootApplication
9+
class ExampleEmbeddedApplication
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package dev.bpmcrafters.example.camunda7embedded.db
2+
3+
import org.springframework.stereotype.Component
4+
import org.springframework.transaction.annotation.Propagation
5+
import org.springframework.transaction.annotation.Transactional
6+
import java.util.*
7+
8+
@Component
9+
class DbService(
10+
val repository: MyEntityRepository
11+
) {
12+
13+
@Transactional(propagation = Propagation.REQUIRES_NEW)
14+
fun save(e: MyEntity) {
15+
repository.save(e)
16+
}
17+
18+
@Transactional(readOnly = true)
19+
fun findById(id: String): Optional<MyEntity> {
20+
return repository.findById(id)
21+
}
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package dev.bpmcrafters.example.camunda7embedded.db
2+
3+
import jakarta.persistence.Column
4+
import jakarta.persistence.Entity
5+
import jakarta.persistence.Id
6+
import jakarta.persistence.Table
7+
8+
@Entity(name = "MyEntity")
9+
@Table(name = "my_entity")
10+
class MyEntity(
11+
@Id
12+
@Column(name = "process_instance_id_")
13+
var processInstanceId: String,
14+
15+
@Column(name = "task_id_", unique = true)
16+
var taskId: String
17+
) {
18+
constructor() : this(processInstanceId = "", taskId = "")
19+
20+
override fun toString(): String {
21+
return "MyEntity(processInstanceId='$processInstanceId', taskId='$taskId')"
22+
}
23+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package dev.bpmcrafters.example.camunda7embedded.db
2+
3+
import org.springframework.data.repository.CrudRepository
4+
5+
interface MyEntityRepository : CrudRepository<MyEntity, String>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package dev.bpmcrafters.example.camunda7embedded.worker
2+
3+
import dev.bpmcrafters.example.camunda7embedded.db.DbService
4+
import dev.bpmcrafters.example.camunda7embedded.db.MyEntity
5+
import dev.bpmcrafters.processengine.worker.BpmnErrorOccurred
6+
import dev.bpmcrafters.processengine.worker.ProcessEngineWorker
7+
import dev.bpmcrafters.processengineapi.CommonRestrictions
8+
import dev.bpmcrafters.processengineapi.task.TaskInformation
9+
import io.github.oshai.kotlinlogging.KotlinLogging
10+
import org.springframework.stereotype.Component
11+
import org.springframework.transaction.annotation.Transactional
12+
import kotlin.jvm.Throws
13+
14+
val logger = KotlinLogging.logger {}
15+
16+
@Component
17+
@Transactional
18+
class ExecuteActionWorker(
19+
private val dbService: DbService
20+
) {
21+
22+
@ProcessEngineWorker(topic = "execute-action")
23+
fun execute(taskInformation: TaskInformation): Map<String, Any> {
24+
val id = taskInformation.meta[CommonRestrictions.PROCESS_INSTANCE_ID] as String
25+
dbService.save(
26+
MyEntity(taskId = taskInformation.taskId, processInstanceId = id)
27+
)
28+
return mapOf("executed" to true)
29+
}
30+
31+
@ProcessEngineWorker(topic = "execute-action-with-error")
32+
fun executeWithError(taskInformation: TaskInformation): Map<String, Any> {
33+
val id = taskInformation.meta[CommonRestrictions.PROCESS_INSTANCE_ID] as String
34+
dbService.save(
35+
MyEntity(taskId = taskInformation.taskId, processInstanceId = id)
36+
)
37+
throw IllegalArgumentException("executeWithError")
38+
}
39+
40+
@ProcessEngineWorker(topic = "execute-action-with-bpmn-error")
41+
@Throws(BpmnErrorOccurred::class)
42+
fun executeWithBpmnError(taskInformation: TaskInformation): Map<String, Any> {
43+
val id = taskInformation.meta[CommonRestrictions.PROCESS_INSTANCE_ID] as String
44+
dbService.save(
45+
MyEntity(taskId = taskInformation.taskId, processInstanceId = id)
46+
)
47+
throw BpmnErrorOccurred("BPMN Error Occurred", "bpmn-error")
48+
}
49+
50+
@ProcessEngineWorker(topic = "check-entity", autoComplete = true)
51+
fun checkCommitedEntity(taskInformation: TaskInformation) {
52+
val id = taskInformation.meta[CommonRestrictions.PROCESS_INSTANCE_ID] as String
53+
dbService.findById(id).ifPresent {
54+
e -> logger.info { "Found entity with id $id: created in task ${e.taskId}" }
55+
}
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
3+
* under one or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information regarding copyright
5+
* ownership. Camunda licenses this file to you under the Apache License,
6+
* Version 2.0; you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
export default {
19+
// // change the app name and vendor
20+
// app: {
21+
// name: 'Operations',
22+
// vendor: 'Company'
23+
// },
24+
customScripts: [
25+
// // If you have a folder called 'my-custom-script' (in the 'cockpit' folder)
26+
// // with a file called 'customScript.js' in it
27+
// // 'my-custom-script/customScript'
28+
'scripts/definition-historic-activities.js',
29+
'scripts/instance-historic-activities.js',
30+
'scripts/instance-route-history.js'
31+
// 'scripts/instance-tab-modify.js'
32+
],
33+
// requireJsConfig: {
34+
// // AngularJS module names
35+
// ngDeps: ['ui.bootstrap'],
36+
// // RequireJS configuration for a complete configuration documentation see:
37+
// // http://requirejs.org/docs/api.html#config
38+
// deps: ['jquery', 'custom-ui'],
39+
// paths: {
40+
// // if you have a folder called `custom-ui` (in the `cockpit` folder)
41+
// // with a file called `scripts.js` in it and defining the `custom-ui` AMD module
42+
// 'custom-ui': 'custom-ui/scripts'
43+
// }
44+
// },
45+
// historicActivityInstanceMetrics: {
46+
// adjustablePeriod: true,
47+
// //select from the default time period: day, week, month, complete
48+
// period: {
49+
// unit: 'week'
50+
// }
51+
// },
52+
// runtimeActivityInstanceMetrics: {
53+
// display: true
54+
// },
55+
// 'locales': {
56+
// 'availableLocales': ['en', 'de'],
57+
// 'fallbackLocale': 'en'
58+
// },
59+
// skipCustomListeners: {
60+
// default: true,
61+
// hidden: false
62+
// },
63+
// skipIoMappings: {
64+
// default: true,
65+
// hidden: false
66+
// },
67+
// 'batchOperation' : {
68+
// // select mode of query for process instances or decision instances
69+
// // possible values: filter, search
70+
// 'mode': 'filter',
71+
//
72+
// // select if Historic Batches should be loaded automatically when navigating to #/batch
73+
// 'autoLoadEnded': true
74+
// },
75+
bpmnJs: {
76+
// moddleExtensions: {
77+
// // if you have a folder called 'my-custom-moddle' (in the 'cockpit' folder)
78+
// // with a file called 'camunda.json' in it defining the 'camunda' moddle extension
79+
// camunda: 'my-custom-moddle/camunda'
80+
// },
81+
additionalModules: [
82+
// // if you have a folder called 'my-custom-module' (in the 'cockpit' folder)
83+
// // with a file called 'module.js' in it
84+
// 'my-custom-module/module'
85+
'scripts/robot-module.js'
86+
],
87+
},
88+
// defaultFilter: {
89+
// historicProcessDefinitionInstancesSearch: {
90+
// lastDays: 5,
91+
// event: 'started'
92+
// }
93+
// },
94+
// csrfCookieName: 'XSRF-TOKEN',
95+
disableWelcomeMessage: true,
96+
// userOperationLogAnnotationLength: 5000,
97+
previewHtml: true
98+
};

0 commit comments

Comments
 (0)