7 changed files with 179 additions and 0 deletions
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
||||
|
||||
plugins { |
||||
id("org.springframework.boot") version "2.7.4" |
||||
id("io.spring.dependency-management") version "1.0.14.RELEASE" |
||||
kotlin("jvm") version "1.7.20" |
||||
kotlin("plugin.spring") version "1.7.20" |
||||
} |
||||
|
||||
java.sourceCompatibility = JavaVersion.VERSION_17 |
||||
|
||||
group = "tech.lusilf" |
||||
version = "0.0.1-SNAPSHOT" |
||||
|
||||
configurations { |
||||
compileOnly { |
||||
extendsFrom(configurations.annotationProcessor.get()) |
||||
} |
||||
} |
||||
|
||||
repositories { |
||||
mavenCentral() |
||||
} |
||||
|
||||
dependencies { |
||||
implementation("org.springframework.boot:spring-boot-starter-web") |
||||
implementation("org.springframework.boot:spring-boot-starter-data-jpa") |
||||
|
||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin") |
||||
implementation("org.jetbrains.kotlin:kotlin-reflect") |
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") |
||||
|
||||
implementation("org.springframework.boot:spring-boot-starter-actuator") |
||||
|
||||
implementation("org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-webapp:7.17.0") |
||||
|
||||
implementation("io.github.microutils:kotlin-logging-jvm:3.0.0") |
||||
|
||||
runtimeOnly("org.postgresql:postgresql") |
||||
|
||||
developmentOnly("org.springframework.boot:spring-boot-devtools") |
||||
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") |
||||
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test") |
||||
} |
||||
|
||||
tasks.withType<KotlinCompile> { |
||||
kotlinOptions { |
||||
freeCompilerArgs = listOf("-Xjsr305=strict") |
||||
jvmTarget = "17" |
||||
} |
||||
} |
||||
|
||||
tasks.withType<Test> { |
||||
useJUnitPlatform() |
||||
} |
||||
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
package tech.lusilf.camunda.external.task.playground.camunda.engine |
||||
|
||||
import mu.KotlinLogging |
||||
import org.camunda.bpm.engine.RuntimeService |
||||
import org.camunda.bpm.engine.delegate.DelegateExecution |
||||
import org.camunda.bpm.engine.delegate.JavaDelegate |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication |
||||
import org.springframework.boot.runApplication |
||||
import org.springframework.stereotype.Service |
||||
import org.springframework.web.bind.annotation.PostMapping |
||||
import org.springframework.web.bind.annotation.RequestBody |
||||
import org.springframework.web.bind.annotation.RestController |
||||
import kotlin.random.Random |
||||
|
||||
@SpringBootApplication |
||||
class CamundaEngineApp |
||||
|
||||
fun main(args: Array<String>) { |
||||
runApplication<CamundaEngineApp>(*args) |
||||
} |
||||
|
||||
@RestController("process") |
||||
class ProcessStarterController( |
||||
private val runtimeService: RuntimeService, |
||||
) { |
||||
|
||||
private val log = KotlinLogging.logger { } |
||||
private val random = Random(5) |
||||
|
||||
@PostMapping("start") |
||||
fun startProcesses(@RequestBody request: StartProcessRequest) { |
||||
|
||||
for (i in 0..request.count) { |
||||
val businessKey = "$i-${random.nextInt()}" |
||||
runtimeService.startProcessInstanceByKey("test-process", businessKey) |
||||
log.info { "Started process - $businessKey" } |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Service("logEnding") |
||||
class LogEndingDelegate : JavaDelegate { |
||||
|
||||
private val log = KotlinLogging.logger { } |
||||
|
||||
override fun execute(execution: DelegateExecution) { |
||||
log.info { "Completing task - ${execution.businessKey}" } |
||||
} |
||||
} |
||||
|
||||
data class StartProcessRequest( |
||||
val count: Int, |
||||
) |
||||
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
camunda: |
||||
bpm: |
||||
authorization: |
||||
enabled: false |
||||
admin-user: |
||||
id: admin |
||||
password: admin |
||||
|
||||
spring: |
||||
datasource: |
||||
url: jdbc:postgresql://localhost:5432/camunda-external-task-playground |
||||
username: postgres |
||||
password: postgres |
||||
driver-class-name: org.postgresql.Driver |
||||
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0s6ce93" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.2.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.17.0"> |
||||
<bpmn:process id="test-process" isExecutable="true"> |
||||
<bpmn:startEvent id="StartEvent_1"> |
||||
<bpmn:outgoing>Flow_0exlht9</bpmn:outgoing> |
||||
</bpmn:startEvent> |
||||
<bpmn:sequenceFlow id="Flow_0exlht9" sourceRef="StartEvent_1" targetRef="Activity_1uixwdp" /> |
||||
<bpmn:sequenceFlow id="Flow_0ku5oz1" sourceRef="Activity_1uixwdp" targetRef="Activity_1x1w9ky" /> |
||||
<bpmn:endEvent id="Event_07xk29k"> |
||||
<bpmn:incoming>Flow_10w1h01</bpmn:incoming> |
||||
</bpmn:endEvent> |
||||
<bpmn:sequenceFlow id="Flow_10w1h01" sourceRef="Activity_1x1w9ky" targetRef="Event_07xk29k" /> |
||||
<bpmn:serviceTask id="Activity_1uixwdp" name="External" camunda:type="external" camunda:topic="test-external-task"> |
||||
<bpmn:incoming>Flow_0exlht9</bpmn:incoming> |
||||
<bpmn:outgoing>Flow_0ku5oz1</bpmn:outgoing> |
||||
</bpmn:serviceTask> |
||||
<bpmn:serviceTask id="Activity_1x1w9ky" name="Delegate" camunda:delegateExpression="${logEnding}"> |
||||
<bpmn:incoming>Flow_0ku5oz1</bpmn:incoming> |
||||
<bpmn:outgoing>Flow_10w1h01</bpmn:outgoing> |
||||
</bpmn:serviceTask> |
||||
</bpmn:process> |
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> |
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="test-process"> |
||||
<bpmndi:BPMNEdge id="Flow_0exlht9_di" bpmnElement="Flow_0exlht9"> |
||||
<di:waypoint x="215" y="97" /> |
||||
<di:waypoint x="270" y="97" /> |
||||
</bpmndi:BPMNEdge> |
||||
<bpmndi:BPMNEdge id="Flow_0ku5oz1_di" bpmnElement="Flow_0ku5oz1"> |
||||
<di:waypoint x="370" y="97" /> |
||||
<di:waypoint x="430" y="97" /> |
||||
</bpmndi:BPMNEdge> |
||||
<bpmndi:BPMNEdge id="Flow_10w1h01_di" bpmnElement="Flow_10w1h01"> |
||||
<di:waypoint x="530" y="97" /> |
||||
<di:waypoint x="592" y="97" /> |
||||
</bpmndi:BPMNEdge> |
||||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> |
||||
<dc:Bounds x="179" y="79" width="36" height="36" /> |
||||
</bpmndi:BPMNShape> |
||||
<bpmndi:BPMNShape id="Event_07xk29k_di" bpmnElement="Event_07xk29k"> |
||||
<dc:Bounds x="592" y="79" width="36" height="36" /> |
||||
</bpmndi:BPMNShape> |
||||
<bpmndi:BPMNShape id="Activity_1pus681_di" bpmnElement="Activity_1uixwdp"> |
||||
<dc:Bounds x="270" y="57" width="100" height="80" /> |
||||
<bpmndi:BPMNLabel /> |
||||
</bpmndi:BPMNShape> |
||||
<bpmndi:BPMNShape id="Activity_0vjtpb0_di" bpmnElement="Activity_1x1w9ky"> |
||||
<dc:Bounds x="430" y="57" width="100" height="80" /> |
||||
<bpmndi:BPMNLabel /> |
||||
</bpmndi:BPMNShape> |
||||
</bpmndi:BPMNPlane> |
||||
</bpmndi:BPMNDiagram> |
||||
</bpmn:definitions> |
||||
Loading…
Reference in new issue