Spring Boot integration with a differnet database schema

Hi,

I’m trying to integrate Flowable into an existing Spring Boot application and I need to use different db/schema for Flowable tables for several reasons: we use Flyway for migrations and jOOQ with its code generation on top of db schema. So, I want to move Flowable tables to a separate schema in PostgreSQL.

I’ve added ProcessEngine bean to an app configuration:
@Bean
ProcessEngine processEngine() {
return SpringProcessEngineConfiguration.createStandaloneProcessEngineConfiguration()
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
.setJdbcDriver(“org.postgresql.Driver”)
.setJdbcUrl(“jdbc:postgresql://localhost:5432/mydb?currentSchema=flowable”)
.setJdbcUsername(“user”)
.setJdbcPassword("")
.buildProcessEngine();
}

As a result, tables were successfully created in the flowable schema, but then I’m getting “relation “act_ge_property” does not exist” exception, and looks like app repository tries to find tables in a default public schema.

What I’m missing during a configuration?

I suppose that there is some conflict between your own ProcessEngineConfiguration and the flowable Spring boot configuration?

Are you using the flowable auto configuration?

I would suggest you to have a look at the ProcessEngineAutoConfiguration. What you need to do is to provide your own bean of SpringProcessEngineConfiguration and when creating that provide your own configuration and pass your own configured DataSource.

Or in order to keep the same defaults you could provide a custom EngineConfigurationConfigurer<SpringProcessEngineConfiguration> and pass your own DataSource to the Flowable engine configuration.

Yes, I’m using auto-configuration which comes with flowable-spring-boot-starter package. Thanks for pointing me to EngineConfigurationConfigurer – now it works with a bean like this:
@Bean
EngineConfigurationConfigurer EngineConfigurationConfigurer(@Qualifier(“flowableDataSource”) DataSource dataSource) {
return engineConfiguration -> engineConfiguration.setDataSource(dataSource);
}

Hi
Would you mind sharing more details of how your solved this?

I used to have some my application with BPMN processes running in Java SE standalone. But today I’m required to migrate to Spring Boot which I never used. So far I’m able to load a sample process and create tasks by following Spring Boot + Flowable instructions, its going well, but I’m having a harder time moving from h2 DB to postgres. Specifically I don’t see clearly how to set up the processEngineConfiguration bean.

Thanks a lot.

@allanberrocal I think that your use case is different than @dstropalov. He has a more complex requirement (in comparison to you, I suppose).
If you have a normal Spring Boot project (with the Spring Boot starter as a parent) then the only thing that you need to do is to add the postgresql driver

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
</dependency>

Why do you think you need to setup the processEngineConfiguration bean?

Thank you for the quick answer.

To include the dependency that’s correct. I’m wondering how I should initialise the connection to the DB in the ProcessEngineConfiguration. For instance, the below snippet shows how I was doing it before.

ProcessEngineConfiguration procEngConfig = new StandaloneProcessEngineConfiguration()
      .setJdbcUrl("jdbc:postgresql://localhost:5432/flowable")
      .setJdbcUsername("usr")
      .setJdbcPassword("pwd")
      .setJdbcDriver("org.postgresql.Driver")
      .setAsyncExecutorActivate(true)
      .setDatabaseType(ProcessEngineConfiguration.DATABASE_TYPE_POSTGRES)
      .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
      ;

I’m not sure how to accomplish this in the Spring Boot paradigm.

@filiphr is right, there is no need in setting ProcessEngine bean configuration in your case. All you need (in a case of a regular Spring Boot application) is to configure a data source (look at this tutorial http://zetcode.com/springboot/postgresql/), and once you’ll have it configured, Flowable will use PostgreSQL, no other configuration is needed.

1 Like

Ahh perfect. I will check the reference right away.

Thank you @filiphr and @dstropalov for your help!

Be sure that you’re using org.flowable:flowable-spring-boot-starter dependency in your project, because it provides auto configuration for Flowable in a Spring Boot environment.

One other thing to note which I am not 100% sure how the entire starter will behave. As there the SpringAppEngineConfiguration is in the lead. Which means that you might need to configure the EngageEngineConfigurationConfigurer<SpringAppEngineConfiguration> and set the DataSource there.

Hi
I’m searching also how to separate flowable tables from my business database. I tried this bean
@Bean
EngineConfigurationConfigurer EngineConfigurationConfigurer(@Qualifier(“flowableDataSource”) DataSource dataSource) {
return engineConfiguration -> engineConfiguration.setDataSource(dataSource);
}
but what i noticed that even it created the flowable tables in the dedicated database, some of my business tables were created in flowable database, so would you mind sharing more details of how your solved this?

How did you get the flowable datasource to set in EngineConfigurationConfigurer? @filiphr