Browse Source

Test external task

master
Anton Aleksanin 3 years ago
parent
commit
3b166df5f0
  1. 5
      camunda-engine/build.gradle.kts
  2. 60
      external-task-app/build.gradle.kts
  3. 47
      external-task-app/src/main/kotlin/tech/lusilf/camunda/external/task/playground/external/task/ExternalTaskApp.kt
  4. 7
      external-task-app/src/main/resources/application.yml
  5. 2
      settings.gradle.kts

5
camunda-engine/build.gradle.kts

@ -26,13 +26,16 @@ dependencies { @@ -26,13 +26,16 @@ 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("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-webapp:7.17.0")
implementation("org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-rest:7.17.0")
implementation("io.github.microutils:kotlin-logging-jvm:3.0.0")

60
external-task-app/build.gradle.kts

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
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-webflux")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.camunda.bpm.springboot:camunda-bpm-spring-boot-starter-external-task-client:7.17.0")
implementation("javax.xml.bind:jaxb-api:2.3.1")
implementation("io.github.microutils:kotlin-logging-jvm:3.0.0")
developmentOnly("org.springframework.boot:spring-boot-devtools")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}

47
external-task-app/src/main/kotlin/tech/lusilf/camunda/external/task/playground/external/task/ExternalTaskApp.kt vendored

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
package tech.lusilf.camunda.external.task.playground.external.task
import mu.KotlinLogging
import org.camunda.bpm.client.impl.ExternalTaskClientBuilderImpl
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.stereotype.Service
import javax.annotation.PostConstruct
import javax.annotation.PreDestroy
@SpringBootApplication
class ExternalTaskApp
fun main(args: Array<String>) {
runApplication<ExternalTaskApp>(*args)
}
@Service
class ExternalTask {
private val log = KotlinLogging.logger { }
private val builder = ExternalTaskClientBuilderImpl()
.baseUrl("http://localhost:8080/engine-rest/")!!
.maxTasks(5)
private val taskClient = builder.build()!!
@PostConstruct
fun init() {
taskClient
.subscribe("test-external-task")
.lockDuration(10000)
.handler { externalTask, externalService ->
log.info { "Handling - ${externalTask.businessKey}" }
Thread.sleep(1000)
log.info { "Completing - ${externalTask.businessKey}" }
externalService.complete(externalTask)
}
.open()
}
@PreDestroy
fun destroy() {
taskClient.stop()
}
}

7
external-task-app/src/main/resources/application.yml

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
server:
port: 8080
camunda:
bpm:
client:
base-url: http://localhost:8080/engine-rest/

2
settings.gradle.kts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
rootProject.name = "camunda-external-task-playground"
include("camunda-engine")
//include("external-task-app")
include("external-task-app")
Loading…
Cancel
Save