-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #328 from camunda-community-hub/55-process-subscri…
…ption feat: Add subscriptions for process and process instance updates
- Loading branch information
Showing
23 changed files
with
1,139 additions
and
578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,99 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.zeebe.zeeqs</groupId> | ||
<artifactId>zeeqs-root</artifactId> | ||
<version>2.6.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>data</artifactId> | ||
<name>ZeeQS - Data</name> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.module</groupId> | ||
<artifactId>jackson-module-kotlin</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.camunda</groupId> | ||
<artifactId>zeebe-bpmn-model</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.postgresql</groupId> | ||
<artifactId>postgresql</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>postgresql</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>default</id> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
</execution> | ||
<!-- run the tests for each supported database --> | ||
<execution> | ||
<id>postgres</id> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<spring.profiles.active>postgres-docker</spring.profiles.active> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.zeebe.zeeqs</groupId> | ||
<artifactId>zeeqs-root</artifactId> | ||
<version>2.6.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>data</artifactId> | ||
<name>ZeeQS - Data</name> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.projectreactor</groupId> | ||
<artifactId>reactor-core</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.module</groupId> | ||
<artifactId>jackson-module-kotlin</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.camunda</groupId> | ||
<artifactId>zeebe-bpmn-model</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.postgresql</groupId> | ||
<artifactId>postgresql</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>postgresql</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>default</id> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
</execution> | ||
<!-- run the tests for each supported database --> | ||
<execution> | ||
<id>postgres</id> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<spring.profiles.active>postgres-docker</spring.profiles.active> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
data/src/main/kotlin/io/zeebe/zeeqs/data/reactive/DataUpdatesPublisher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package io.zeebe.zeeqs.data.reactive | ||
|
||
import io.zeebe.zeeqs.data.entity.* | ||
import org.springframework.stereotype.Component | ||
import java.util.function.Consumer | ||
|
||
@Component | ||
class DataUpdatesPublisher { | ||
|
||
private val processListeners = mutableListOf<Consumer<Process>>() | ||
private val processInstanceListeners = mutableListOf<Consumer<ProcessInstance>>() | ||
private val elementInstanceListeners = mutableListOf<Consumer<ElementInstance>>() | ||
private val variableListeners = mutableListOf<Consumer<Variable>>() | ||
private val incidentListeners = mutableListOf<Consumer<Incident>>() | ||
private val jobListeners = mutableListOf<Consumer<Job>>() | ||
|
||
fun onProcessUpdated(process: Process) { | ||
processListeners.forEach { it.accept(process) } | ||
} | ||
|
||
fun onProcessInstanceUpdated(processInstance: ProcessInstance) { | ||
processInstanceListeners.forEach { it.accept(processInstance) } | ||
} | ||
|
||
fun onElementInstanceUpdated(elementInstance: ElementInstance) { | ||
elementInstanceListeners.forEach { it.accept(elementInstance) } | ||
} | ||
|
||
fun onVariableUpdated(variable: Variable) { | ||
variableListeners.forEach { it.accept(variable) } | ||
} | ||
|
||
fun onIncidentUpdated(incident: Incident) { | ||
incidentListeners.forEach { it.accept(incident) } | ||
} | ||
|
||
fun onJobUpdated(job: Job) { | ||
jobListeners.forEach { it.accept(job) } | ||
} | ||
|
||
fun registerProcessListener(listener: Consumer<Process>) { | ||
processListeners.add(listener) | ||
} | ||
|
||
fun registerProcessInstanceListener(listener: Consumer<ProcessInstance>) { | ||
processInstanceListeners.add(listener) | ||
} | ||
|
||
fun registerElementInstanceListener(listener: Consumer<ElementInstance>) { | ||
elementInstanceListeners.add(listener) | ||
} | ||
|
||
fun registerVariableListener(listener: Consumer<Variable>) { | ||
variableListeners.add(listener) | ||
} | ||
|
||
fun registerIncidentListener(listener: Consumer<Incident>) { | ||
incidentListeners.add(listener) | ||
} | ||
|
||
fun registerJobListener(listener: Consumer<Job>) { | ||
jobListeners.add(listener) | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
data/src/main/kotlin/io/zeebe/zeeqs/data/reactive/DataUpdatesSubscription.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package io.zeebe.zeeqs.data.reactive | ||
|
||
import io.zeebe.zeeqs.data.entity.Process | ||
import org.springframework.stereotype.Component | ||
import reactor.core.publisher.Flux | ||
|
||
@Component | ||
class DataUpdatesSubscription(private val publisher: DataUpdatesPublisher) { | ||
|
||
fun processSubscription(): Flux<Process> { | ||
return Flux.create { sink -> | ||
publisher.registerProcessListener { sink.next(it) } | ||
} | ||
} | ||
|
||
fun processInstanceUpdateSubscription(): Flux<ProcessInstanceUpdate> { | ||
return Flux.create { sink -> | ||
publisher.registerProcessInstanceListener { | ||
sink.next(ProcessInstanceUpdate( | ||
processInstanceKey = it.key, | ||
processKey = it.processDefinitionKey, | ||
updateType = ProcessInstanceUpdateType.PROCESS_INSTANCE_STATE | ||
)) | ||
} | ||
|
||
publisher.registerElementInstanceListener { | ||
sink.next(ProcessInstanceUpdate( | ||
processInstanceKey = it.processInstanceKey, | ||
processKey = it.processDefinitionKey, | ||
updateType = ProcessInstanceUpdateType.ELEMENT_INSTANCE | ||
)) | ||
} | ||
|
||
publisher.registerVariableListener { | ||
sink.next(ProcessInstanceUpdate( | ||
processInstanceKey = it.processInstanceKey, | ||
processKey = it.processDefinitionKey, | ||
updateType = ProcessInstanceUpdateType.VARIABLE | ||
)) | ||
} | ||
|
||
publisher.registerIncidentListener { | ||
sink.next(ProcessInstanceUpdate( | ||
processInstanceKey = it.processInstanceKey, | ||
processKey = it.processDefinitionKey, | ||
updateType = ProcessInstanceUpdateType.INCIDENT | ||
)) | ||
} | ||
|
||
publisher.registerJobListener { | ||
sink.next(ProcessInstanceUpdate( | ||
processInstanceKey = it.processInstanceKey, | ||
processKey = it.processDefinitionKey, | ||
updateType = ProcessInstanceUpdateType.JOB | ||
)) | ||
} | ||
} | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
data/src/main/kotlin/io/zeebe/zeeqs/data/reactive/ProcessInstanceUpdate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.zeebe.zeeqs.data.reactive | ||
|
||
data class ProcessInstanceUpdate( | ||
val processInstanceKey: Long, | ||
val processKey: Long, | ||
val updateType: ProcessInstanceUpdateType | ||
) |
9 changes: 9 additions & 0 deletions
9
data/src/main/kotlin/io/zeebe/zeeqs/data/reactive/ProcessInstanceUpdateType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.zeebe.zeeqs.data.reactive | ||
|
||
enum class ProcessInstanceUpdateType { | ||
PROCESS_INSTANCE_STATE, | ||
ELEMENT_INSTANCE, | ||
VARIABLE, | ||
INCIDENT, | ||
JOB | ||
} |
Oops, something went wrong.