5 changed files with 119 additions and 2 deletions
@ -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() |
||||
} |
||||
@ -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() |
||||
} |
||||
} |
||||
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
server: |
||||
port: 8080 |
||||
|
||||
camunda: |
||||
bpm: |
||||
client: |
||||
base-url: http://localhost:8080/engine-rest/ |
||||
Loading…
Reference in new issue