Commit 8da6ca04a8a1a21f88f8b89abaffb0154bbe92b3
1 parent
f8ebdbdd
feat(BPM): AsyncTaskExecutor 如果不创建,会导致项目启动时,Flowable 报错的问题
Showing
1 changed file
with
23 additions
and
0 deletions
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java
| @@ -11,9 +11,12 @@ import org.flowable.common.engine.api.delegate.event.FlowableEventListener; | @@ -11,9 +11,12 @@ import org.flowable.common.engine.api.delegate.event.FlowableEventListener; | ||
| 11 | import org.flowable.spring.SpringProcessEngineConfiguration; | 11 | import org.flowable.spring.SpringProcessEngineConfiguration; |
| 12 | import org.flowable.spring.boot.EngineConfigurationConfigurer; | 12 | import org.flowable.spring.boot.EngineConfigurationConfigurer; |
| 13 | import org.springframework.beans.factory.ObjectProvider; | 13 | import org.springframework.beans.factory.ObjectProvider; |
| 14 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
| 14 | import org.springframework.context.ApplicationEventPublisher; | 15 | import org.springframework.context.ApplicationEventPublisher; |
| 15 | import org.springframework.context.annotation.Bean; | 16 | import org.springframework.context.annotation.Bean; |
| 16 | import org.springframework.context.annotation.Configuration; | 17 | import org.springframework.context.annotation.Configuration; |
| 18 | +import org.springframework.core.task.AsyncTaskExecutor; | ||
| 19 | +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
| 17 | 20 | ||
| 18 | import java.util.List; | 21 | import java.util.List; |
| 19 | 22 | ||
| @@ -26,6 +29,26 @@ import java.util.List; | @@ -26,6 +29,26 @@ import java.util.List; | ||
| 26 | public class BpmFlowableConfiguration { | 29 | public class BpmFlowableConfiguration { |
| 27 | 30 | ||
| 28 | /** | 31 | /** |
| 32 | + * 参考 {@link org.flowable.spring.boot.FlowableJobConfiguration} 类,创建对应的 AsyncListenableTaskExecutor Bean | ||
| 33 | + * <p> | ||
| 34 | + * 如果不创建,会导致项目启动时,Flowable 报错的问题 | ||
| 35 | + */ | ||
| 36 | + @Bean(name = "applicationTaskExecutor") | ||
| 37 | + @ConditionalOnMissingBean(name = "applicationTaskExecutor") | ||
| 38 | + public AsyncTaskExecutor taskExecutor() { | ||
| 39 | + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | ||
| 40 | + executor.setCorePoolSize(8); | ||
| 41 | + executor.setMaxPoolSize(8); | ||
| 42 | + executor.setQueueCapacity(100); | ||
| 43 | + executor.setThreadNamePrefix("flowable-task-Executor-"); | ||
| 44 | + executor.setAwaitTerminationSeconds(30); | ||
| 45 | + executor.setWaitForTasksToCompleteOnShutdown(true); | ||
| 46 | + executor.setAllowCoreThreadTimeOut(true); | ||
| 47 | + executor.initialize(); | ||
| 48 | + return executor; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 29 | * BPM 模块的 ProcessEngineConfigurationConfigurer 实现类: | 52 | * BPM 模块的 ProcessEngineConfigurationConfigurer 实现类: |
| 30 | * | 53 | * |
| 31 | * 1. 设置各种监听器 | 54 | * 1. 设置各种监听器 |