如何正确使用 Camunda / Spring Boot 示例应用程序

How to properly use Camunda / Springboot sample application

我正在关注 Canmunda 提供的 Springboot 教程:

https://github.com/camunda/camunda-bpm-examples/tree/master/spring-boot-starter/example-simple

安装项目后运行ning

java -jar target/camunda-bpm-spring-boot-starter-example-simple-0.0.1-SNAPSHOT.jar

我在 运行 输出末尾收到此错误:

2021-07-05 11:37:24.970  INFO 52476 --- [   scheduling-1] org.camunda.bpm.container                : ENGINE-08051 Process application mySimpleApplication undeployed
2021-07-05 11:37:24.971  INFO 52476 --- [   scheduling-1] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'
2021-07-05 11:37:24.975  INFO 52476 --- [   scheduling-1] org.camunda.bpm.engine                   : ENGINE-00007 Process Engine default closed
2021-07-05 11:37:24.976  INFO 52476 --- [   scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2021-07-05 11:37:24.989  WARN 52476 --- [   scheduling-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Interrupted during closing

java.lang.InterruptedException: null
        at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1649) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.awaitTermination(ThreadPoolExecutor.java:1456) ~[na:na]
        at com.zaxxer.hikari.pool.HikariPool.shutdown(HikariPool.java:255) ~[HikariCP-3.4.5.jar!/:na]
        at com.zaxxer.hikari.HikariDataSource.close(HikariDataSource.java:351) ~[HikariCP-3.4.5.jar!/:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
        at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:281) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:215) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:587) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:559) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1152) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:520) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1145) ~[spring-beans-5.3.5.jar!/:5.3.5]
        at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1106) ~[spring-context-5.3.5.jar!/:5.3.5]
        at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1075) ~[spring-context-5.3.5.jar!/:5.3.5]
        at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1021) ~[spring-context-5.3.5.jar!/:5.3.5]
        at org.springframework.boot.SpringApplication.close(SpringApplication.java:1371) ~[spring-boot-2.4.4.jar!/:2.4.4]
        at org.springframework.boot.SpringApplication.exit(SpringApplication.java:1358) ~[spring-boot-2.4.4.jar!/:2.4.4]
        at org.camunda.bpm.spring.boot.example.simple.SimpleApplication.exitApplicationWhenProcessIsFinished(SimpleApplication.java:106) ~[classes!/:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
        at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.3.5.jar!/:5.3.5]
        at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.3.5.jar!/:5.3.5]
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
        at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[na:na]
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:831) ~[na:na]

2021-07-05 11:37:25.251  INFO 52476 --- [   scheduling-1] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'camundaTaskExecutor'

我可以做些什么来使这个例子 运行 正确?

只需在-jar之前的命令中添加-Dorg.camunda.bpm.spring.boot.starter.example.simple.SimpleApplication.exitWhenFinished=false:

java -Dorg.camunda.bpm.spring.boot.starter.example.simple.SimpleApplication.exitWhenFinished=false -jar target/camunda-bpm-spring-boot-starter-example-simple-0.0.1-SNAPSHOT.jar

该标志有效,因为 example-simple 定义了它 @ https://github.com/camunda/camunda-bpm-examples/blob/e10193855e874abce2eb9e463b47f97954c54d57/spring-boot-starter/example-simple/src/main/java/org/camunda/bpm/spring/boot/example/simple/SimpleApplication.java#L74 and checks the value must be true before exiting the application @ https://github.com/camunda/camunda-bpm-examples/blob/e10193855e874abce2eb9e463b47f97954c54d57/spring-boot-starter/example-simple/src/main/java/org/camunda/bpm/spring/boot/example/simple/SimpleApplication.java#L104

或者,如果您想永久删除该功能,只需从 SimpleApplication class.

中删除 exitApplicationWhenProcessIsFinished() 功能