Skip to content

Commit 39f5950

Browse files
authored
Merge pull request #190 from emaarco/develop
refactor: generate spring metadata-files & update docs
2 parents 896c369 + 961f53f commit 39f5950

14 files changed

Lines changed: 128 additions & 48 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ build/
4444
### DEV
4545
_tmp/
4646
.repository/
47+
.claude

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ ZEEBE_CLIENT_ID=..
171171
ZEEBE_CLIENT_SECRET=...
172172
```
173173

174-
After starting application, you can either use Open API endpoints or just run the
174+
After starting application, you can either use Open API endpoints or just run the
175175
HTTP client tests using your IntelliJ, located in the example directory.
176176

177-
Don't forget to first deploy the process! Either manually via operate / modeler, or with the HTTP client script: c8-deploy-process.http
177+
Don't forget to first deploy the process!
178+
Either manually via operate / modeler, or with the HTTP client script:
179+
c8-deploy-process.http
180+

docs/process-engine-worker.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ title: Process Engine Worker
33
---
44

55
Process Engine Worker is an independent component built on top of Process Engine API in order to accelerate the development of agnostic workers
6-
for any process engine supported by Process Engine API in Spring Boot ecosystem. By doing so, it abstracts from specific worker clients and
6+
for any process engine supported by Process Engine API in Spring Boot ecosystem. By doing so, it abstracts from specific worker clients and
77
API and allows to build universal workers.
88

9-
First of all add the Process Engine Worker dependency to your projects classpath. In Maven add the following to you `pom.xml`:
9+
First of all add the Process Engine Worker dependency to your projects classpath. In Maven add the following to your `pom.xml`:
1010

1111
```xml
1212
<dependency>
@@ -72,9 +72,22 @@ is a checked exception, in order to comply with Spring behavior of not rolling b
7272

7373
The worker method can be marked transactional by adding Spring or Jakarta EE transactional annotations to the method or to the worker class.
7474
If the annotation `@org.springframework.transaction.annotation.Transactional` with propagation `REQUIRES`, `REQUIRES_NEW`, `SUPPORTS` and `MANDATORY`
75-
is used, the library will execute the worker method and the completion of the external task via API in the same transaction. This will lead to
75+
is used, the library will execute the worker method and the completion of the external task via API in the same transaction. This will lead to
7676
a transaction rollback, if the external task can't be completed (e.g. due to a network error).
7777

78+
## Configuration
79+
80+
You can configure the Process Engine Worker by adding the following properties to your `application.properties` or `application.yml`:
81+
82+
```yaml
83+
dev:
84+
bpm-crafters:
85+
process-api:
86+
worker:
87+
registerProcessWorkers: true # Enable or disable automatic worker registration
88+
completeTasksBeforeCommit: false # Determines whether tasks are completed before transaction commit
89+
```
90+
7891
7992
8093

examples/order-fulfillment/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@
123123
<testSourceDirectory>src/test/java</testSourceDirectory>
124124

125125
<plugins>
126+
<plugin>
127+
<groupId>org.apache.maven.plugins</groupId>
128+
<artifactId>maven-compiler-plugin</artifactId>
129+
<configuration>
130+
<annotationProcessorPaths>
131+
<path>
132+
<groupId>org.projectlombok</groupId>
133+
<artifactId>lombok</artifactId>
134+
</path>
135+
</annotationProcessorPaths>
136+
</configuration>
137+
</plugin>
126138
<plugin>
127139
<groupId>org.jetbrains.kotlin</groupId>
128140
<artifactId>kotlin-maven-plugin</artifactId>

pom.xml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@
4646
<artifactId>mockito-kotlin</artifactId>
4747
<version>${mockito.version}</version>
4848
</dependency>
49-
<dependency>
50-
<groupId>com.tngtech.archunit</groupId>
51-
<artifactId>archunit-junit5</artifactId>
52-
<version>${archunit.version}</version>
53-
</dependency>
5449
</dependencies>
5550
</dependencyManagement>
5651

@@ -194,7 +189,7 @@
194189
<organizationUrl>https://holisticon.de</organizationUrl>
195190
</developer>
196191
<developer>
197-
<id>__</id>
192+
<id>stephanpelikan</id>
198193
<name>Stephan Pelikan</name>
199194
<roles>
200195
<role>Developer</role>
@@ -212,7 +207,7 @@
212207
<organizationUrl>https://phactum.at</organizationUrl>
213208
</developer>
214209
<developer>
215-
<id>__</id>
210+
<id>dominikhorn93</id>
216211
<name>Dominik Horn</name>
217212
<roles>
218213
<role>Developer</role>
@@ -221,13 +216,22 @@
221216
<organizationUrl>https://miragon.com</organizationUrl>
222217
</developer>
223218
<developer>
224-
<id>__</id>
225-
<name>Thomas Hinrichs</name>
219+
<id>Hafflgav</id>
220+
<name>Thomas Heinrichs</name>
226221
<roles>
227222
<role>Developer</role>
228223
</roles>
229224
<organization>Miragon</organization>
230225
<organizationUrl>https://miragon.com</organizationUrl>
231226
</developer>
227+
<developer>
228+
<id>emaarco</id>
229+
<name>Marco Schäck</name>
230+
<roles>
231+
<role>Developer</role>
232+
</roles>
233+
<organization>Miragon</organization>
234+
<organizationUrl>https://miragon.io</organizationUrl>
235+
</developer>
232236
</developers>
233237
</project>

spring-boot-starter/pom.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@
7272
<groupId>com.fasterxml.jackson.datatype</groupId>
7373
<artifactId>jackson-datatype-jsr310</artifactId>
7474
</dependency>
75+
<dependency>
76+
<groupId>org.springframework.boot</groupId>
77+
<artifactId>spring-boot-configuration-processor</artifactId>
78+
<optional>true</optional>
79+
</dependency>
7580

7681
<!-- Testing -->
7782
<dependency>
@@ -126,4 +131,33 @@
126131
</dependency>
127132
</dependencies>
128133

134+
<build>
135+
<plugins>
136+
<plugin>
137+
<groupId>org.jetbrains.kotlin</groupId>
138+
<artifactId>kotlin-maven-plugin</artifactId>
139+
<executions>
140+
<execution>
141+
<id>kapt</id>
142+
<goals>
143+
<goal>kapt</goal>
144+
</goals>
145+
<configuration>
146+
<sourceDirs>
147+
<sourceDir>src/main/kotlin</sourceDir>
148+
</sourceDirs>
149+
<annotationProcessorPaths>
150+
<annotationProcessorPath>
151+
<groupId>org.springframework.boot</groupId>
152+
<artifactId>spring-boot-configuration-processor</artifactId>
153+
<version>${spring-boot.version}</version>
154+
</annotationProcessorPath>
155+
</annotationProcessorPaths>
156+
</configuration>
157+
</execution>
158+
</executions>
159+
</plugin>
160+
</plugins>
161+
</build>
162+
129163
</project>

spring-boot-starter/src/main/kotlin/dev/bpmcrafters/processengine/worker/FailJobException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import java.time.Duration
44

55
/**
66
* Exception for failing a job.
7-
* Allows to set the available retries and the backoff time for the retry.
7+
* Allows setting the available retries and the backoff time for the retry.
88
*/
99
class FailJobException(
1010
message: String,

spring-boot-starter/src/main/kotlin/dev/bpmcrafters/processengine/worker/configuration/ProcessEngineWorkerAutoConfiguration.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import dev.bpmcrafters.processengine.worker.registrar.metrics.ProcessEngineWorke
66
import dev.bpmcrafters.processengine.worker.registrar.metrics.ProcessEngineWorkerMetricsNoOp
77
import io.micrometer.core.instrument.MeterRegistry
88
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean
9-
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
109
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
1110
import org.springframework.boot.context.properties.EnableConfigurationProperties
1211
import org.springframework.context.annotation.Bean
@@ -25,11 +24,15 @@ class ProcessEngineWorkerAutoConfiguration {
2524
*/
2625
@Bean
2726
@ConditionalOnMissingBean
28-
fun defaultJacksonVariableConverter(objectMapper: ObjectMapper): VariableConverter = JacksonVariableConverter(objectMapper = objectMapper)
27+
fun defaultJacksonVariableConverter(
28+
objectMapper: ObjectMapper,
29+
): VariableConverter = JacksonVariableConverter(
30+
objectMapper = objectMapper
31+
)
2932

3033
/**
3134
* Initializes parameter resolver.
32-
* If you want to add your own parameter resolver, just create your own parameter resolver and expose it as bean. You might want
35+
* If you want to add your own parameter resolver, create your own parameter resolver and expose it as bean. You might want
3336
* to register your own strategies using the [ParameterResolver.ParameterResolverBuilder#addStrategy] method.
3437
*/
3538
@Bean
@@ -38,15 +41,15 @@ class ProcessEngineWorkerAutoConfiguration {
3841

3942
/**
4043
* Initializes result resolver.
41-
* If you want to add your own result resolver, just create you own result resolver and expose it as a bean. You might want
42-
* to register you own strategy using [ResultResolver.ResultResolverBuilder#addStrategy] method.
44+
* If you want to add your own result resolver, create your own result resolver and expose it as a bean.
45+
* You might want to register your own strategy using the [ResultResolver.ResultResolverBuilder#addStrategy] method.
4346
*/
4447
@Bean
4548
@ConditionalOnMissingBean
4649
fun defaultResultResolver() = ResultResolver.builder().build()
4750

4851
/**
49-
* Micrometer based metrics.
52+
* Micrometer-based metrics.
5053
*/
5154
@Bean
5255
@ConditionalOnBean(MeterRegistry::class)

spring-boot-starter/src/main/kotlin/dev/bpmcrafters/processengine/worker/configuration/ProcessEngineWorkerDeploymentAutoConfiguration.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,23 @@ class ProcessEngineWorkerDeploymentAutoConfiguration {
3232
) = ProcessDeployment(
3333
resourcePatternResolver = resourcePatternResolver,
3434
deploymentApi = deploymentApi,
35-
processEngineWorkerDeploymentProperties = processEngineWorkerDeploymentProperties
35+
deploymentProperties = processEngineWorkerDeploymentProperties
3636
)
3737

3838
/**
3939
* Configures a trigger for auto-deployment triggered by application start event.
4040
*/
4141
@ConditionalOnProperty(
42-
prefix = ProcessEngineWorkerDeploymentProperties.PREFIX,
42+
prefix = ProcessEngineWorkerDeploymentProperties.DEFAULT_PREFIX,
4343
name = ["enabled"],
4444
havingValue = "true",
4545
matchIfMissing = false
4646
)
4747
@Bean
48-
fun autoDeploymentOnStartup(processDeployment: ProcessDeployment) =
49-
AutoDeploymentOnStartup(processDeployment = processDeployment)
48+
fun autoDeploymentOnStartup(
49+
processDeployment: ProcessDeployment
50+
) = AutoDeploymentOnStartup(
51+
processDeployment = processDeployment
52+
)
5053

5154
}
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
package dev.bpmcrafters.processengine.worker.configuration
22

3-
import dev.bpmcrafters.processengine.worker.configuration.ProcessEngineWorkerDeploymentProperties.Companion.PREFIX
3+
import dev.bpmcrafters.processengine.worker.configuration.ProcessEngineWorkerDeploymentProperties.Companion.DEFAULT_PREFIX
44
import org.springframework.boot.context.properties.ConfigurationProperties
5+
import org.springframework.validation.annotation.Validated
56

67
/**
78
* Configuration properties for the deployment feature.
89
*/
9-
@ConfigurationProperties(prefix = PREFIX)
10-
class ProcessEngineWorkerDeploymentProperties(
10+
@Validated
11+
@ConfigurationProperties(prefix = DEFAULT_PREFIX)
12+
data class ProcessEngineWorkerDeploymentProperties(
1113
/**
1214
* Pattern to scan for BPMN resources.
1315
*/
14-
val bpmnResourcePattern: String = "classpath*:/**/*.bpmn",
16+
var bpmnResourcePattern: String = "classpath*:/**/*.bpmn",
1517
/**
1618
* Pattern to scan fo DMN resources.
1719
*/
18-
val dmnResourcePattern: String = "classpath*:/**/*.dmn",
20+
var dmnResourcePattern: String = "classpath*:/**/*.dmn",
1921
/**
2022
* Flag to control if the feature is active, defaults to `false`.
2123
*/
22-
val enabled: Boolean = false,
24+
var enabled: Boolean = false,
2325
/**
2426
* Deployment timeout, defaults to 30 seconds.
2527
*/
26-
val deploymentTimeoutInSeconds: Long = 30,
28+
var deploymentTimeoutInSeconds: Long = 30,
2729
) {
2830
companion object {
29-
const val PREFIX = ProcessEngineWorkerProperties.PREFIX + ".deployment"
31+
const val DEFAULT_PREFIX = ProcessEngineWorkerProperties.DEFAULT_PREFIX + ".deployment"
3032
}
3133
}

0 commit comments

Comments
 (0)