Spring Boot Separate DataSource Properties File

Good day. First of all, Thank you guys for this BPM. Recently, we wanted to make app with bpm and found this open source light weight bpm. I know you had been working in alfresco activiti. I hope you are doing well.

So my problem is:
I have an issue with spring boot. Sorry for the issue, i earlier asked for similar problem. Currently flowable bpm uses my default database configured in application.properties file, when i startup my app. Though i want bpm to use some flowable.properties file so it could save tables in separate datasource. Using flowable.cgf.xml file seems uneasy because beans are not autoinjected.
Could you consider such feature, special properties file for datasource.
I think it is crucial, because bpm tables and my tables are mixed in one database schema.
In addition, i want beans to be autoinjected. However, at least could you provide an example.

Have you tried using 2 beans, one for primary the other for activiti:

Something like :

  @Bean
  @Primary
  @ConfigurationProperties(prefix = "spring.datasource")
  public DataSource primaryDataSource() {
    return DataSourceBuilder
        .create()
        .url(dataSourceProperties.getUrl())
        .username(dataSourceProperties.getUsername())
        .password(dataSourceProperties.getPassword())
        .driverClassName(dataSourceProperties.getDriverClassName())
        .build();
  }


  @Bean
  @ConfigurationProperties(prefix = "spring.activiti.datasource")
  public DataSource activitiDataSource() {
    return DataSourceBuilder
        .create()
        .url(activitiDataSourceProperties.getUrl())
        .username(dataSourceProperties.getUsername())
        .password(dataSourceProperties.getPassword())
        .driverClassName(dataSourceProperties.getDriverClassName())
        .build();
  }

Good idea. I should try it. However, properties file is far better approach, because you do not need to change source code.

Adding the option to the flowable.properties file makes sense I think. But you are aware that this means you need a JTA transaction manager in Spring boot because you are working with multiple data sources from the same application, right? If you more transaction participants (like a message queue etc), then this makes sense anyway, but if you add the JTA transaction manager just because of handling multiple data sources, you might want to consider using the same database schema or separating the application in two parts if possible.

Best regards,

Tijs

Hello. Yeah, that’s a quite complicated issue, i didn’t expect. You are right. May be the better approach at least is to use separate schema in one database, which is fine for us. That should work and can be configured through flowable.properties or in our application.properties file with flowable.bpm.datasource option.

Hi,

Having a separate schema in one database still means having multiple DataSource connection pools on a Spring boot application level. So you would still need a JTA transaction manager to manage multiple data sources. Or you need to switch between schema’s on a connection pool level, but that requires some custom coding I think.

Best regards,

Tijs

Hi tijs,
Was it added to flowable.properties ? Is it possible to choose the correct data source via a properties file?
If not, maybe there’s another way ? (maybe by extending a Flowable class?)

We would love an example if it’s possible.

Thanks.

Might be late to reply but we implemented it by using flowable properties.
We are using Oracle DB which is used as the primary data source for the Spring boot project.
To use flowable in a different schema, add following properties to your properties file -

> flowable.database-schema=<your schema name>
> flowable.database-schema-update=true

Hope this helps!