Open ruixule opened 1 year ago
我是单独给它配数据源的
@Data
@Configuration
public class FlowableEngineConfig implements EngineConfigurationConfigurer
我是单独给它配数据源的 @DaTa @configuration public class FlowableEngineConfig implements EngineConfigurationConfigurer { /* jdbc 驱动类 / @value("${spring.datasource.driver-class-name}") private String jdbcDriver; / jdbc url / @value("${spring.datasource.url}") private String jdbcUrl; / jdbc 用户名 / @value("${spring.datasource.username}") private String jdbcUsername; / jdbc 密码 */ @value("${spring.datasource.password}") private String jdbcPassword; 。。。 @OverRide public void configure(SpringProcessEngineConfiguration engineConfiguration) { engineConfiguration.setActivityFontName("宋体"); engineConfiguration.setLabelFontName("宋体"); engineConfiguration.setAnnotationFontName("宋体"); engineConfiguration.setJdbcDriver(this.jdbcDriver); engineConfiguration.setJdbcUrl(this.jdbcUrl); engineConfiguration.setJdbcUsername(this.jdbcUsername); engineConfiguration.setJdbcPassword(this.jdbcPassword); engineConfiguration.setDatabaseSchemaUpdate(this.databaseSchemaUpdate); engineConfiguration.setAsyncExecutorActivate(this.asyncExecutorActivate); } 。。。
你这边是整合的flowable-spring-boot-starter 还是只是engine呢
我是单独给它配数据源的 @DaTa @configuration public class FlowableEngineConfig implements EngineConfigurationConfigurer { /* jdbc 驱动类 / @value("${spring.datasource.driver-class-name}") private String jdbcDriver; / jdbc url / @value("${spring.datasource.url}") private String jdbcUrl; / jdbc 用户名 / @value("${spring.datasource.username}") private String jdbcUsername; / jdbc 密码 */ @value("${spring.datasource.password}") private String jdbcPassword; 。。。 @OverRide public void configure(SpringProcessEngineConfiguration engineConfiguration) { engineConfiguration.setActivityFontName("宋体"); engineConfiguration.setLabelFontName("宋体"); engineConfiguration.setAnnotationFontName("宋体"); engineConfiguration.setJdbcDriver(this.jdbcDriver); engineConfiguration.setJdbcUrl(this.jdbcUrl); engineConfiguration.setJdbcUsername(this.jdbcUsername); engineConfiguration.setJdbcPassword(this.jdbcPassword); engineConfiguration.setDatabaseSchemaUpdate(this.databaseSchemaUpdate); engineConfiguration.setAsyncExecutorActivate(this.asyncExecutorActivate); } 。。。
还有就是请问下,你是如何处理 业务库和flowable数据库 的事务管理的?一起会滚或者一起提交的呢
兄弟,问题解决了吗?切换+事务
整合的flowable-spring-boot-starter,我用的切面解决的数据源问题
package xxxx.flowable.config;
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; import lombok.extern.slf4j.Slf4j; import org.flowable.common.engine.impl.AbstractEngineConfiguration; import org.flowable.common.engine.impl.EngineConfigurator; import org.flowable.engine.ProcessEngine; import org.flowable.eventregistry.spring.configurator.SpringEventRegistryConfigurator; import org.flowable.spring.SpringProcessEngineConfiguration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.sql.DataSource;
@Slf4j @Configuration public class FlowableConfig {
@Autowired
private DynamicRoutingDataSource dynamicRoutingDataSource;
@Bean
public EngineConfigurator customEngineConfigurator() {
return new EngineConfigurator() {
@Override
public void beforeInit(AbstractEngineConfiguration engineConfiguration) {
DataSource dataSource = dynamicRoutingDataSource.getDataSource("flowable");
engineConfiguration.setDataSource(dataSource);
}
@Override
public int getPriority() {
// 返回的值越小,优先级越高。这里返回0,表示最高优先级。
return 0;
}
@Override
public void configure(AbstractEngineConfiguration processEngineConfiguration) {
// 在这里添加你的自定义配置逻辑
// 例如,可以设置自定义的表单类型解析器或自定义的脚本任务执行器
System.out.println("Custom Engine Configurator with highest priority is being applied.");
}
};
}
@Bean
public SpringEventRegistryConfigurator customEventEngineConfigurator() {
return new SpringEventRegistryConfigurator() {
@Override
public void beforeInit(AbstractEngineConfiguration engineConfiguration) {
DataSource dataSource = dynamicRoutingDataSource.getDataSource("tenant");
engineConfiguration.setDataSource(dataSource);
}
@Override
public int getPriority() {
// 返回的值越小,优先级越高。这里返回0,表示最高优先级。
return 0;
}
@Override
public void configure(AbstractEngineConfiguration processEngineConfiguration) {
// 在这里添加你的自定义配置逻辑
System.out.println("Custom Engine Configurator with highest priority is being applied.");
}
};
}
@Bean
public ProcessEngine processEngine(SpringProcessEngineConfiguration configuration) {
// 将自定义的EngineConfigurator添加到SpringProcessEngineConfiguration
configuration.getProcessEngineConfiguration().addConfigurator(customEngineConfigurator());
configuration.getProcessEngineConfiguration().addConfigurator(customEventEngineConfigurator());
// 构建并返回流程引擎
return configuration.buildProcessEngine();
}
}
整合的flowable-spring-boot-starter,我用的切面解决的数据源问题
package xxx.flowable.config; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.*; import org.springframework.stereotype.Component;
/**
flowable:6.8.0,spring boot v2.2.2.RELEASE */ @Slf4j @Component @Aspect public class DbAspect {
@Pointcut("execution(* org.flowable.app.engine.AppEngineConfiguration.buildAppEngine())") public void buildEngine() {}
@Pointcut("execution(* org.flowable.eventregistry.spring.SpringEventRegistryEngineConfiguration.start())") public void startRegistry() {}
@Around("buildEngine()") public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { log.info("初始化flowable-engine之前切换到工作流数据源"); DynamicDataSourceContextHolder.push("flowable"); Object result = proceedingJoinPoint.proceed(); log.info("初始化flowable-engine之后停用工作流数据源"); DynamicDataSourceContextHolder.poll(); return result; } @Around("startRegistry()") public Object doAroundStartRegistry(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { log.info("初始化flowable-event-registry之前切换到工作流数据源"); DynamicDataSourceContextHolder.push("flowable"); Object result = proceedingJoinPoint.proceed(); log.info("初始化flowable-event-registry之后停用工作流数据源"); DynamicDataSourceContextHolder.poll(); return result; } }
你用的是哪个版本,为啥我用的6.4.2这个版本还是不行
你用的是哪个版本,为啥我用的6.4.2这个版本还是不行
我用的工作流版本是6.8,切面应该可以。第一种方法我也能切过来
在 flowable springboot start中,当主要业务有3个以上的mysql 数据源时,在没有配置默认数据库的情况下, 给flowable 单独配置一个数据源, 为什么还会去找 业务的3个数据源呢?而不是使用自己的单独配置的数据源呢?
In the flowable spring boot start, when there are three or more MySQL data sources for the main business, without configuring a default database,
Why would you still look for three data sources for your business when configuring a separate data source for Flowable? Instead of using your own separately configured data source?